Page 1 of 1

suggestions on trimming scanner output

Posted: 2016-07-12T20:02:21-07:00
by jasonblewis
Hi,

I want to automate scanning and trimming a bunch of documents. I am hoping to use sane to scan and then imagemagick to post process.

I'm scanning on a brother ADS-2100e

When I scan, the scanner puts grey borders down the side of the image and a white border at the bottom of the image like these:

https://flic.kr/p/JZVdPu
https://flic.kr/p/JTKcvu

I've not been very successful with using the trim command to trim off those borders. I've even tried adding a white border around the whole image and then trimming that off, and then adding a grey border and trimming that off with a fuzz level but I always seem to end up with a white bar at the bottom that prevents the grey being trimmed off.

Result of: mogrify -trim +repage *.pnm
https://flic.kr/p/K2CcGS
https://flic.kr/p/J9gZcp

Any suggestions for the best approach to this? I'm looking for something that is automatic and can cope with differences from scan to scan so I don't have to look at each scan.

What about if I try and replace the grey and white with a known odd colour, then trim that colour?

Re: suggestions on trimming scanner output

Posted: 2016-07-12T20:19:18-07:00
by fmw42
Try using -fuzz XX% -trim (multiple times), such as

Code: Select all

convert 28152554082_0ce150132b_o.png -fuzz 25% -trim -trim result.png
This gets you down to the base image which shows some slight rotation.

In the future, please provide your IM version and platform.

See the top-most post in this forum IMPORTANT: Please Read This FIRST Before Posting

Re: suggestions on trimming scanner output

Posted: 2016-07-12T20:49:01-07:00
by jasonblewis
Appologies, here they are somewhat late.

Debian Jessie GNU/Linux
ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 http://www.imagemagick.org

Thanks for your example, that seems to work well.

Re: suggestions on trimming scanner output

Posted: 2016-07-12T22:05:45-07:00
by fmw42
The reason for the version information is that syntax may differ for Unix and Windows systems and for scripting