Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function resizeImage($pic_type, $sourcePath, $destPath, $maxWidth, $maxHeight)
- {
- switch ($pic_type) {
- case 'png':
- $size = getimagesize($sourcePath);
- if ($size[1] / $size[0] > $maxHeight / $maxWidth) {
- $newHeight = $maxHeight;
- $newWidth = ceil($size[0] / $size[1] * $newHeight);
- } else {
- $newWidth = $maxWidth;
- $newHeight = ceil($size[1] / $size[0] * $newWidth);
- }
- $image = imagecreatefrompng($sourcePath);
- $newImage = imagecreatetruecolor($newWidth, $newHeight);
- imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $size[0], $size[1]);
- imagepng($newImage, $destPath);
- imagedestroy($image);
- imagedestroy($newImage);
- break;
- }
- }
- // Verkleinern für die Vorschau
- $this->resizeImage($ava_type, $upload_direction, $ava_tpath . 'thumb_' . $ava_fname . '.' . $ava_type, 500, 500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement