Page 1 of 1

Thumbnail function now creates "grey" thumbnails?

Posted: Thu Jun 16, 2005 1:17 pm
by webcan
Hey guys -

I have this function:

Code: Select all

function createThumbnail($image_path, $image_id, $file, $width, $height, $compression) { 
        copy($file, "$image_path/$image_id");
	    $src_img = imagecreatefromJPEG("$image_path/$image_id"); 
	    $new_h = $height;
	    $new_w = $width;
	    $dst_img = imagecreate($new_w,$new_h); 
	    imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); 
	    imagejpeg($dst_img, "$image_path/$image_id", $compression); 
	}
It used to work fine, all the thumbnails were created reasonably well. But recently we updated the version of PHP and now the thumbnails come out very grey looking. It appears if some of the colors are just "missing" (although it's not quite black&white).

Any suggestions what I can do to fix it?

Thanks,
Peter.

Posted: Thu Jun 16, 2005 1:35 pm
by John Cartwright
Try replacing imagecreate() with imagecreatetruecolor().

Posted: Thu Jun 16, 2005 1:41 pm
by webcan
Thank you!

That seems to have worked.

Weird that it worked in the older version of PHP without problem though!

Posted: Thu Jun 16, 2005 2:27 pm
by pickle
Also, use imagecopyresampled() rather than imagecopyresized() if you have GD2. imagecopyresampled() actually resamples the image so you get a much smoother, cleaner looking thumbnail.