Hi
I have this script working so far.
It get gets an image, resizes the shortest edge to 300, now I need it to crop the image so that it is 300x300 (from the center). I have tried so many different ways that I'm totally confused and would be eternally grateful if anyone can give me any ideas.
$img = "pathtoimage.jpg";
$size = GetImageSize($img);
// if Wide Image
if($size[0] > $size[1]) {
$thumbnail_height = 300;
$thumbnail_width = (int)(300 * $size[0]/size[1]);
} else{
//if Tall Image
$thumbnail_height = (int)(300 * $size[1] / $size[0]);
$thumbnail_width = 300;
}
$mogrify = "pathtoImageMagick/mogrify -geometry";
system("$mogrify $thumbnail_heightx$thumbnail_width $img", $exec_retval);
I have this script working so far.
It get gets an image, resizes the shortest edge to 300, now I need it to crop the image so that it is 300x300 (from the center). I have tried so many different ways that I'm totally confused and would be eternally grateful if anyone can give me any ideas.
$img = "pathtoimage.jpg";
$size = GetImageSize($img);
// if Wide Image
if($size[0] > $size[1]) {
$thumbnail_height = 300;
$thumbnail_width = (int)(300 * $size[0]/size[1]);
} else{
//if Tall Image
$thumbnail_height = (int)(300 * $size[1] / $size[0]);
$thumbnail_width = 300;
}
$mogrify = "pathtoImageMagick/mogrify -geometry";
system("$mogrify $thumbnail_heightx$thumbnail_width $img", $exec_retval);