Friday, December 11, 2015

How to crop cut image using ImageMagick

To crop an image using ImageMagick, you need to specify the X and Y coordinates of the top corner of the crop rectangle and the width and height of the crop rectangle. Use the mogrify command if you want the images to be replaced in-place or use the convert command otherwise to make a copy.

If you want the crop rectangle to start at top corner X: 50 Y: 100 and the crop rectangle to be of size W: 640 H:480, then use the command:

$ mogrify -crop 640x480+50+100 foo.png

To write the cropped image to a new file:

$ convert foo.png -crop 640x480+50+100 out.png


No comments: