...

View Full Version : Thumbnail Gif



jhl84
07-25-2007, 03:53 AM
I want to create a image thumbnails. I basically use the same code for jpeg and the image is perfect. But for gif, the image color is distorted. I'm not sure if distorted is the word, but the color is totally out. How do I rectify this problem?


if (@$userfile_type=="image/gif")
{
$im=ImageCreateFromGIF($add);
//$width=ImageSx($im); // Original picture width is stored
//$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {

ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {

ImageJPEG($newimage,$tsrc,100);
}
chmod("$tsrc",0777);
}

mlseim
07-25-2007, 04:52 AM
I just answered this for someone else ....

Use resample instead of resize.

See this example page:

http://www.catpin.com/scott.php

In the example, I didn't deal with the transparent color.
There is a function for handling transparent .gif colors.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum