Hello
I have the following code which I use to create a 90x120 thumbnail of image $src_img_name from /images and put it in /thumbs with the same name.
But, when it runs, it won't resize properly. It seems to just copy an unresized segment of the image, resizes it in a strange way and uses that as the thumbnail. The final thumb is 100x100px rather that 120x90, but why I cannot see. See the effect at my site (choose one of the last thumbs to see the full image). There is also a black area (aways of the same size) at the bottom of each thumb. This is presumably due to the blank created while copying a 90px high image onto a 100px high blank image.
$image_width, $image_height are the source image's dimensions
$src_img = imagecreatefromjpeg("./images/".$src_img_name); // Get source image
$dst_img = imagecreatetruecolor(120, 90); // Create thumbnail image
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 120, 90, $image_width, $image_height); // Make a 120x90 version of the source and copy it as the thumbnail image
imagejpeg($dst_img, "./thumbs/".$src_img_name, 100); // Save thumbnail image
imagedestroy($src_img); // Clear data
imagedestroy($dst_img);
Many thanks!
PS I have the necessary GD 2.1 installed