hi again,
I'm finally getting close to get the thumbnail generation working,but I have a new problem.I'm using the script bellow to create thumbnails from uploaded gif and jpeg images.Everything is working correctly when i upload a gif image,the original image is uploaded and the thumbnail is created.But when I try to upload a jpeg image,the thumbnail is not created,although the original image is uploaded just fine.
I don't get any errors,that's why I can't find what's going wrong.
If you can take a look at the script,maybe there's something wrong that I can't see...
please help! 😕
<?php
////$add is defined before this code/////
$n_width=100; // Fix the width of the thumb nail images
$n_height=100; // Fix the height of the thumb nail imaage
$tsrc= "/my/thumb/folder" . $HTTP_POST_FILES['userfile']['name']; // Path where thumb nail image will be stored
if ($HTTP_POST_FILES['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")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
if($HTTP_POST_FILES['userfile']['type']=="image/pjpeg"){
$im=ImageCreateFromJPEG($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);
ImageJpeg($newimage,$tsrc);
}
chmod("$tsrc",0777);
}
}
?>