Linux: Quick multiple page scanning with scanimage
It’s often required to scan a lot of pages in one go, even manually. The problem is that when doing individual scans, there’s a significant delay between each scans, as the computer initializes the scanner for each.
The trick is to use scanimage’s batch scan feature. A typical command for scanning an 10 A4 pages with color into the current directory:
$ scanimage -y 297 --format pnm --batch=scan%04d.pnm --batch-count=10 --resolution 150 --mode Color
Stopping the sequence before the count given (on an HP Officejet 4500 all-in-one) with CTRL-C results in a message saying that the scanning is stopped, and indeed it is. Only the program has to be killed manually, and the scanner unplugged from power, and then powered up again. That aggressive.
Interesting variations:
- For B/W scanning (which is significantly faster), go –mode Gray instead
- The first number used in the file names can be set with –batch-start
- To stop between each scan and wait for the user to press RETURN, add the –batch-prompt flag
Before starting this, it’s recommended to run gthumb on the current directory, so the images can be inspected on the fly:
$ gthumb . &
And after finishing the session, it can be nice to convert the scans to JPG:
$ for i in *.pnm ; do convert $i ${i%%.pnm}.jpg ; done
Even though scanimage –help supplies options that imply that JPEG can be obtained directly from the scanner, it seems like scanimage doesn’t play ball with this.
Reader Comments
hi,
I was looking for the file name format (increase numbering) and save in my folder.
I also use the ENTER key to start scan between each page (–batch-prompt).
thanks.
you script:
“–format=png –batch=/home/myfolder/scan%04d.png”
is ok.
thanks