I'm Parker.

Scanning from the Command Line in a Snap

Julia Evans recently wrote about the tiny personal programs she’s written, one of which was called “getting my scanner to work better.” She links to her wrapper for scanimage which got me thinking: is it possible to use scanimage with my Fujitsu ScanSnap S1100?

I love this little ScanSnap S1100 for its miniature size and ease of use. Unfortunately it comes with bloated software which doesn’t quite meet the privacy trust threshold for me. Since I like the scanner but don’t like the first-party software, I figured this was a perfect opportunity to see if I could get scanimage to work.

Some Googling later, I found the SANE project, where “SANE” stands for “Scanner Access Now Easy.” As a macOS user, I immediately searched Homebrew, where I found sane-backends, a package which would ostensibly give me the scanimage binary and the backend firmware needed for my scanner.

With my scanner plugged in, I ran scanimage but got the error scanimage: no SANE devices found. Huh? My scanner was definitely plugged in. System Report on the Mac told me so. The sane-backends package comes with a helpful binary called sane-find-scanner, but I got another error there too: could not fetch string descriptor: Pipe error. Not very helpful.

Back to Google, to figure out why the program couldn’t find my scanner. A number of forums referenced these mysterious .nal files. I decided to see if I had this .nal file in the sane-backends installation. Unfortunately I did not. There’s a file called etc/sane.d/epjitsu.conf which referenced a .nal file for the Fujifilm S1100 I had plugged in, but the file it referenced didn’t exist. That’s odd – I would have expected “sane-backends” to include the backends for the scanners.

A bit more Googling and I found a GitHub repository which contained the necessary files and I cloned it into the directory where the epjitsu.conf file was expecting it to be. I re-ran sane-find-scanner and – hooray! – it registered. I ran scanimage and finally got something!

With scanimage successfully working, I decided to modify Julia’s scan.sh script for my needs. I decided to use tiff as the output format and use --batch-prompt so that I could feed the ScanSnap (the default batch behavior expects you have a feeder scanner which pulls in each page one at a time without human intervention). I ran my custom script and – oops! - no convert binary in sight. This binary is provided by the imagemagick package, so back to Homebrew to install that. Once that was sorted, I successfully made my tiff scans and converted them into a PDF.

I chose TIFF for its quality. When scanning a document, I want it to be crisp to promote readability and better quality if it gets printed from these scans. Unfortunately, TIFF files can be massive. A single page was just over 1MB, and somehow convert created a PDF file which was 348 MB large – huge when the input was only 40 1MB files. Luckily Preview on the Mac has a way to fix this. Open the file, then choose “File -> Export…”. Under the “Quartz Filter” drop-down, there’s an option to choose “Black & White” or “Grey Tone”. Choose either and export. (I found that choosing “Reduce File Size” irreparably reduced the quality, YMMV.)

And finally, the saga was complete. I had my 40-page PDF at a reasonable size! I hope this is useful to others who don’t want to install gigabytes of software from their scanner’s vendor but can’t find a way past the default sane-backends install. Clearly you need to BYOD: bring your own driver. Once you have that in place, you’re golden!