I am writing a PHP script that is supposed to generate a GIF thumbnail file from a specified reagion in a large JPG graphic. What I am finding is that the resulting GIF has a poor color palette and generally is not a good representation of the JPEG. It usually has a monochrome look at best, and at worst has so little contrast that the image is not recognizable.
Is there any way to get an optimized palette in PHP/GD?
Here is a code sample:
$imageHandle = imagecreatefromjpeg($f_imageName);
$thumbHandle = imagecreate(75, 75);
ImageCopyresampled($thumbHandle, $imageHandle, 0, 0,
$leftCoord, $topCoord, 75, 75,
$f_width, $f_width);
imagegif ($thumbHandle, $f_thumbName);
imageDestroy($imageHandle);
imageDestroy($thumbHandle);
Notes:
1) My web host has done something to GD so it supports both GIF and JPEG.
2) using ImageCopyResized doesn't change the resulting GIF at all.
3) If I do an ImageColorsTotal call on the JPEG handle it always returns 0
4) If I do an ImageColorsTotal call on the thumbhandle it returns 0 before the ImageCopy* call and 256 after
5) For some reason I cannot use ImageCreateTrueColor (host related problems).