suggestions on trimming scanner output

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jasonblewis
Posts: 2
Joined: 2016-07-12T19:50:56-07:00
Authentication code: 1151

suggestions on trimming scanner output

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: suggestions on trimming scanner output

Post 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
jasonblewis
Posts: 2
Joined: 2016-07-12T19:50:56-07:00
Authentication code: 1151

Re: suggestions on trimming scanner output

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: suggestions on trimming scanner output

Post by fmw42 »

The reason for the version information is that syntax may differ for Unix and Windows systems and for scripting
Post Reply