so this is not it?
function resize_image($source, $dest, $max_width=60, $max_height=60) {
$source_quality = 80;
$src_img = ImageCreateFromJpeg($source);
$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);
$result = ImageJpeg($dst_img, $dest, $source_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
return $result;
}
function resize_and_crop($source_file, $dest_file, $dest_side = 149) {
// Resize and crop an image to a square image that is filled with
// the source image.
require_once ‘Image/Transform.php’;
$im = Image_Transform::factory(‘GD’);
$im->load($source_file);
if ($im->getImageWidth() > $im->getImageHeight()) {
// L'image d'origine est horizontale.
$im->scaleByY($dest_side ); // scale proportionally the image so the height = 190.
$im->crop($dest_side , $dest_side , ($im->new_x - $dest_side ) / 2, 0);
} else {
// L'image d'origine est verticale.
$im->scaleByX($dest_side ); // scale proportionally the image so the width = 190.
$im->crop($dest_side , $dest_side , 0, ($im->new_y - $dest_side ) / 2);
}
$im->save($dest_file);
$im->free();
return true;
}