If you can use GD2 library use this function
function create_resampled_image($max_height, $max_width, $image_quality,
$image, $newimage){
$src_img = imagecreatefromjpeg($image);
$orig_x = imagesx($src_img);
$orig_y = imagesy($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = imagecreatetruecolor($new_x,$new_y);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x,
$orig_y);
imagejpeg($dst_img, $newimage, $image_quality);
imagedestroy($src_img);
imagedestroy($dst_img);
}
Posts: n/a