Page 1 of 1
Crop and resize (doesn't work)
Posted: 2013-02-17T16:35:24-07:00
by Bilge
I'm using the following command to crop the centre portion of an image and then resize the result.
Code: Select all
convert -gravity center -crop x450 -thumbnail 192x
This completely fails to work and is very frustrating. It takes the first 450 rows from (0,0) instead of from the center and it doesn't bother to thumbnail at all. This is despite
-list gravity showing Center is supported and despite -thumbnail working without the -crop argument.
Why does this command just perform a crop from (0,0) origin instead of a crop from center and then a resize?
Re: Crop and resize (doesn't work)
Posted: 2013-02-17T17:18:52-07:00
by fmw42
You have no input image or output image. So we do not know where you have put it. Also you need to specify both width and height and offsets +repage when cropping. If you leave off the offsets, IM will try to crop the image into multiple parts. See
http://www.imagemagick.org/Usage/crop/#crop_tile. If you leave off the width, IM will use the width of the input image.
Also it would be nice to know what version of IM and what platform you are using. See
viewtopic.php?f=1&t=9620
Try
convert inputimage -gravity center -crop WxH+0+0 +repage -thumbnail 192x outputimage
see
http://www.imagemagick.org/Usage/crop/#crop_gravity
Re: Crop and resize (doesn't work)
Posted: 2013-02-17T17:25:05-07:00
by Bilge
Simply adding +0 to the crop geometry fixed it but I don't understand why. I guess it's to do with the bizarre default behaviour generating a series.
Re: Crop and resize (doesn't work)
Posted: 2013-02-17T20:14:03-07:00
by fmw42
As I said above, IM will try to tile crop the image into parts if you leave off the +0+0.
Re: Crop and resize (doesn't work)
Posted: 2013-02-25T18:42:08-07:00
by anthony
Specifically
If you do not specify an offset of the area to be cropped it will assume you want to generate 'tiles' of that size.
Gravity only sets where the image offset is to be relative to. It does not specify the offset!
If you do not specify a size (width in this case) it is assumed to be the actual image width.
Aside... when virtual canvases are involved it uses the virtual canvas sizes and positions for these defaults.
See IM Example pages on Crop which goes through what crop does when various settings are left off or various flags are used.
http://www.imagemagick.org/Usage/crop/