Remove borders from image using ImageMagick convert
ImageMagick’s “convert” application allows you to easily chop off pixels from the top and left sides using “-chop 5×5″ for example, however, there’s no method to chop from all four at once. It would seem obvious that “-chop 5x5x5x5″ would take off 5 pixels from all four sides, but it doesn’t work that way.
The easiest way to crop a border from an image is to rotate the image as you chop. It’s pretty much the same way you would cut a border from a piece of paper using a pair of scissors unless you were ambidextrous and even then wouldn’t it be faster to just rotate the picture rather than changing scissor hands?
====All in one step====
Chop, rotate, chop, rotate. Done.
$ convert -chop 10×10 -rotate 180 -chop 10×10 -rotate 180 orig.jpg temp.jpg
====Individually it would be tedious====
Chop 10 pixels from the top and left side of the original and save it in a temp file:
$ convert -chop 10×10 -rotate 180 orig.jpg temp.jpg
Chop 10 pixels from the bottom and right side of the temp and overwrite the original:
$ convert -chop 10×10 -rotate 180 temp.jpg orig.jpg
====Batch border chopping====
$ for x in `ls *.jpg`; do convert -chop 10×10 -rotate 180 $x $x_chop.jpg; done