Page 1 of 1

Resize and crop image in single operation

Posted: 2014-02-09T17:16:35-07:00
by wardrop
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:

Code: Select all

mogrify -format jpg -colorspace RGB  -resize "160x160^" -gravity center -crop 160x160+0+0 /tmp/input.jpg
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:

Code: Select all

convert -format jpg -colorspace RGB  -resize "160x160^" -gravity center -crop 160x160+0+0 /tmp/input.jpg /tmp/output.jpg
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?

Re: Resize and crop image in single operation

Posted: 2014-02-09T17:38:30-07:00
by fmw42
Works fine on 6.8.8.5 Q16. My guess is that the ^ symbol was not introduced until after 6.4.3

Checking the changelog, I see ^ was introduced at 6.3.8-2

So I guess it is a bug in 6.4.3