How to crop an image using ImageMagick from the command line?

I am trying to crop a 640x640 image using ImageMagick on the command line.

I need to remove about 20 pixels from the bottom part of the image all the way from left to right. A long strip along the bottom.

I know about the shave command.

What would be the command to enter in the command line? I am using the Windows version of this software.


Assuming that you always know the size of your image you can do it like this:

convert original.jpg -crop 640x620+0+0 cropped.jpg

With the -crop operator you specify the size of the cut out image and the offset from the upper left corner of the old image. In order to get rid of the 20px along the bottom, you have to choose a size of 640x620 and an offset of 0+0


Use ImageMagick's -chop operator as follows to remove 20 rows of pixels from the bottom:

convert image.png -gravity South -chop 0x20 result.png

Change to -gravity North to chop top 20 rows.


Change to:

convert image.png -gravity East -chop 20x0 result.png

to crop from right side, note that the 20 pixels are now before the x separator.