$old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img = ImageCreateTrueColor($thumb_w,$thumb_h); $image = ImageCreateFromJPEG($img); imagecopyresampled($dst_img,$image,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); imagejpeg($dst_img, null, 100); ?>