12

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?

enter image description here

Burgi
  • 6,493
  • 14
  • 39
  • 52
Arek
  • 131
  • 1
  • 5
  • 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 04 '13 at 23:51
  • I want it to be trimmed to the edges of the content. – Arek Oct 06 '13 at 08:12
  • 2
    http://askubuntu.com/questions/97695/is-there-a-lightweight-tool-to-crop-images-quickly || http://stackoverflow.com/questions/14098965/using-imagemagick-how-do-i-crop-out-the-white-background – Ciro Santilli OurBigBook.com Oct 05 '15 at 22:13

1 Answers1

11

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:

output

Andrea
  • 1,516
  • 4
  • 17
  • 19