jhl84
07-25-2007, 02: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);
}
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);
}