Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got some scanned images in *.jpg format. They are scanned using A4 scanner, in greyscale or colour. Scanned pages have very different dimensions - some A5, some A6, some business cards etc. Scanner cover is white.

I want to trim all the white borders using imagemagick or graphicsmagick (those tools, because I want to further batch-process it). I understand that the border is scanned, so not perfecty white and that sometimes can cause trimming too much or too less of the image. However using trim parameter with fuzz I always get too big image. For example, using image of business card below:

gm.exe convert -crop -fuzz 50% 01-pixelated.jpg 01-pixelated-gm.jpg

produces image which is still not cut from the right and bottom. The result is the same no matter what number I put to the -fuzz parameter.

Could you please test it and advise the command line that will do the job?

share|improve this question
Do you want to trim right to the edges of the text / content, or to the edges of the piece of paper, whichever size it is (A4, A5, A6)? In your example, the bottom boundary of the card is not visible at all--I don't know how you expect to detect it. – willus Oct 4 '13 at 23:51
I want it to be trimmed to the edges of the content. – Arek Oct 6 '13 at 8:12
up vote 4 down vote accepted

In ImageMagick try this command:

convert input.jpg -fuzz 80% -trim +repage output.jpg

I tested it with ImageMagick 6.4.4 Q16 and, starting from the image you linked, I obtained this output image:


share|improve this answer
so obvious, I mismatched -trim with -crop. Thank you! – Arek Nov 19 '13 at 16:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.