How can I crop only left and right sides of an image using ImageMagic

Viewed 945

How can I remove a specific number of pixels from left and right sides of an image without knowing the width of the image:

I tried:

convert img.png -crop +200 result.png

But it only removes from the left side

2 Answers

You can use -shave like this to remove 200 pixels from left and right:

convert input.png -shave 200x0 result.png

Or like this for top and bottom:

convert input.png -shave 0x200 result.png

You can use a negative number to remove from the right side:

convert img.png -crop +200 +repage -crop -200 result.png
Related