Hi all -
Trying to work out some problems with my thumbnail script.
here is my script:
//thumbnail width and height
$t_width = 250;
$t_height = 200;
//get file information
list($width, $height, $type) = getimagesize("$dir/$fname/$file");
$ratio_orig = $width/$height;
if ($t_width/$t_height > $ratio_orig) {
$t_width = $t_height * $ratio_orig;
} else {
$t_height = $t_width/$ratio_orig;
}
//Resize
$thumb = imagecreatetruecolor($t_width, $t_height);
$src = imagecreatefromjpeg("$dir/$fname/$file");
imagecopyresampled($thumb, $src, 0, 0, 0, 0, $t_width, $t_height, $width, $height);
imagejpeg($thumb, "{$dir}/{$fname}/thumbs/{$file}", 100);
I’m getting a number of errors that are giving me a headache, let me start with two:
-
$thumb = imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions
I’m getting great thumbanails for both portrait and landscape - any idea as to why this warning is occuring? -
imagejpeg() expects parameter 1 to be resource, boolean given.
I suspect this has to do with my first warning but not sure how to move forward.
Thanks in advance - I’m new to this area of php and any help would be appreciated.