Scanning from the terminal with scanimage

Scanning documents on Linux doesn't have to mean wrestling with a GUI. scanimage, part of the sane-utils Debian package, handles the job directly from the command line using the same SANE ("scanner access now easy") libraries that back most Linux scanning applications. If you don't need OCR, it may be all you need.

Find your scanner

Start by listing available devices:

scanimage -L

If nothing shows up, verify the scanner is actually powered on and connected. A device that's plugged into the computer but not the wall outlet will produce no output.

Once detected, you'll see a device identifier. A typical result looks like fujitsu:ScanSnap S1500:2314 — keep this string handy, as you'll need it for the scan command.

Check scanner-specific options

Every scanner exposes different capabilities, so inspect yours with:

scanimage --help

This shows the available options. For example, a --source option enables duplex (two-sided) scanning, and --resolution lets you trade image quality for smaller files and faster scans — setting it to 150 is a sensible default for archiving documents.

Producing a PDF

scanimage has no PDF output of its own, but a short shell script bridges the gap. The approach: scan each page as a PNG into a temporary directory, then batch-convert them into a single PDF:

#!/bin/bash
set -e

DIR=`mktemp -d`
CUR=$PWD
cd $DIR
scanimage -b --format png  -d 'fujitsu:ScanSnap S1500:2314' --source 'ADF Front' --resolution 150
convert *.png $CUR/$1

Run the script with the output file as an argument:

scan-single-sided output-file-to-save.pdf

You'll need to adjust -d to match your scanner's identifier and --source to your preferred paper feed mode.

It's surprising how smoothly this works in practice. A scanner that seems finicky in a graphical front-end can be perfectly cooperative once you talk to it over the command line.