Canon CanoScan LiDE 210 with SANE
Bought a Canon LiDE 210 the other day mainly because it was cheap enough and does get power over USB. That is one cable less to worry about.
After installing SANE and doing the first scan I was rather disappointed by the result. The pictures were dark and especially for document scans at high resolution the paper structure was clearly visible. It took a while to find a way to make the results decent enough to stick them into a PDF that looked pretty.
Eventually I ended up writing a wrapper script which picks up the scanned image modifies it and sticks it into a PDF. Below is a simplified breakdown of what the script does.
Scanning & Processing
For the scan I use the scanimage tool coming with SANE. For me the basic features worked ok but scanner specific options like brightness adjustment did not work.
scanimage -x 210 -y 297 --resolution 300 --format tiff --mode Color > SCAN.tif
The first step of making the image more document like is with ImageMagick's mogrify or convert and the -despeckle option.
convert -despeckle SCAN.tif SCAN-despeckle.tif
This gets rid of the paper structure but the image is still quite "dirty" the original paper is as white as snow. To get do the desired result the -brightness-contrast option will do with a value of 10x20.
convert -brightness-contrast 10x20 SCAN-despeckle.tif SCAN-despeckle-bc.tif
Scanning into a PDF
With this out of the way combining the commands with a pipe and converting to PDF is quite easy.
scanimage -x 210 -y 297 --resolution 300 --format tiff --mode Color | \ convert \( -despeckle -brightness-contrast 10x20 \) -repage A4 -compress jpeg -quality 90 - SCAN.pdf
Voila, the PDF is ready.