Forum Moderators: coopster
I'm uploading and resizing images so that they fit a maximum height or width, but the problem I'm having is that the quality of the image is really rubbish after it's been resized. Has anyone got any ideas of how to fix that or have experienced the same problem?
code:
<?php
$full_url = "../posterFull/".$id.".jpg";
$imageInfo = getimagesize($imgfile);
$src_width = $imageInfo[0];
$src_height = $imageInfo[1];
$max = checkMax($src_width, $src_height, 340);
($max == 2)? $max = 0 : $max = 1;
$divide = $imageInfo[$max] / 340;
$dest_width = $src_width / $divide;
$dest_height = $src_height / $divide;
$src_img = imagecreatefromjpeg($imgfile);
$dst_img = imagecreate($dest_width,$dest_height);
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagejpeg($dst_img,$full_url);
imagedestroy($src_img);
?>
If anyone can help I'd be much appreciated as I thought this upload thing was under control and I've already wasted 4 hours trying to figure out why it comes out so rubbish on a bank holiday.