Neat script to create a thumbnails no larger than 150 (or user-specific) height AND width.
<?PHP
$picture ="" $max=150; $src_img=ImagecreateFromJpeg($picture);
$oh = imagesy($src_img); $ow = imagesx($src_img); $new_h = $oh;
$new_w = $ow;
if($oh > $max || $ow > $max){
$r = $oh/$ow;
$new_h = ($oh > $ow) ? $max : $max*$r;
$new_w = $new_h/$r;
}
$dst_img = ImageCreateTrueColor($new_w,$new_h);
ImageCopyResized($dst_img, $src_img, 0,0,0,0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img));
ImageJpeg($dst_img, "th_$picture");
?>