Resize and crop image in single operation
Posted: 2014-02-09T17:16:35-07:00
Hi,
I'm trying to resize and crop an image using `mogrify`, but it seems the version of ImageMagick I'm using crops BEFORE resizing. Here's the command I'm using:
On my computer running ImageMagick 6.7.7-6, the above works fine. The image is resized so the smallest dimension is 160 pixels, and it then crops the result. However, on the server I'm deploying to which runs ImageMagick 6.4.3, the operation happens in reverse. The image is cropped first, which obviously produces the wrong result.
If I pass the same parameters to `convert`, it produces the correct result on both versions:
However, I need to make this work using `mogrify` as that what the library I'm using uses in the background. Can anyone tell me how to get the desired result on the slightly older version of ImageMagick running on our production server?
I'm trying to resize and crop an image using `mogrify`, but it seems the version of ImageMagick I'm using crops BEFORE resizing. Here's the command I'm using:
Code: Select all
mogrify -format jpg -colorspace RGB -resize "160x160^" -gravity center -crop 160x160+0+0 /tmp/input.jpg
If I pass the same parameters to `convert`, it produces the correct result on both versions:
Code: Select all
convert -format jpg -colorspace RGB -resize "160x160^" -gravity center -crop 160x160+0+0 /tmp/input.jpg /tmp/output.jpg