imagemagick mogrify cut part of image out

Jared Eitnier picture Jared Eitnier · Apr 12, 2013 · Viewed 10.4k times · Source

If I have an image similar to this:

---------------------------------
-        xxxxxxxxxx             -
-        x        x             -
-        xxxxxxxxxx             -
---------------------------------

How can I use mogrify to cut out just the portion in x's? Do i use -geometry?. I can't find a good example.

Answer

Jim Lindstrom picture Jim Lindstrom · Apr 12, 2013

The imagemagick docs show how to do so with "convert":

http://www.imagemagick.org/Usage/crop/#crop_viewport

There are variations, depending on whether you want to replace the "cut" portion with another color or trim the size down to just the x's (in your diagram).

I'm assuming "mogrify" will do the same thing, but you just don't give an output filename.