Page 1 of 1

Thumbnail Creation of An Image from a directory

Posted: Wed Jul 27, 2005 5:16 am
by lostinphp
Is there anyone who can help me with a minor problem..i have a folder with large images that gets uploaded from a form.i have a thumb folder where thumbnail images of the images from the large folder gets automatically generated.the problem is that the thumbnail image created is nothing but a block of black color.i guess the problem is wid the imagetruecolor option which is not working even wid gd library installed in the project.
so please give your suggestion as to how i can conserve the color of the thumbnail images.
any kind of help will be really helpful.thank u

Posted: Wed Jul 27, 2005 5:35 am
by anjanesh
For jpeg, I use these functions in the following order and it works.

imagecreatefromjpeg
imagecreatetruecolor
imagecopyresized
imagejpeg

help!

Posted: Wed Jul 27, 2005 5:49 am
by lostinphp
thank u but i have used the same thing but it still doesnt work and im still generating black blocks instead of the thumbnail version of the original images.
help!
if($ftype=="image/jpeg"){

$im=ImageCreateFromJPEG($fname);

$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);

ImageJPEG($newimage,$tsrc);

chmod("$tsrc",0777);

}}

Posted: Wed Jul 27, 2005 9:55 am
by pickle
Check your width variables. If any of them are zero, you'll get a black image. Also, use imagecopyresampled() rather than imagecopyresized() if you've got GD 2.0 - it makes much smoother thumbnails.