Code: Select all
function makeThumbs($file){
$target_path = "images/".$file;
$src = imagecreatefromjpeg($target_path);
list($width,$height) = getimagesize($target_path);
if($width>$height){
$new_width = 150;
$new_height = ($height/$width)*$new_width;
}else{
$new_height = 150;
$new_width = ($width/$height)*$new_height;
}
$tmp = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($tmp,$src,0,0,0,0,$new_width,$new_height,$width,$height);
$target_path = "images/thumbs/".$file;
imagejpeg($tmp,$target_path,100);
imagedestroy($src);
imagedestroy($tmp);
}
Then these two images are giving headaches because for whatever reason, they just fail the script:
http://nuphoto.org/temp/1%20free%20internet.jpg
I think this is more of a filename issue, but i tired adding
into the code, and it stopped creating thumbnails....$file = str_replace(" ","%20",$file)
and this:
http://nuphoto.org/temp/605120605341539.jpg
this one is really troublesome. i tried to debug it and found that it kills the script after this line:
help?$src = imagecreatefromjpeg($target_path);