Skip to content

Efficient scanning and storing of documents

I don’t like having an administration in dead-tree format, but there are those who insist on sending you all kinds of things in this format. To make this data easier to access and back up, I scan it to a digital format. I used to do this manually, with the GIMP, but I decided it was time for some automation. Therefore I wrote a script, which scans whatever you put under the lid of the scanner in lineart mode, and stores it very efficiently in a DjVu DjVuBitonal document. And here it is:

#! /bin/bash
# Author: halfgaar
# Prevent attacker from placing unholy replacements of system commands in your
# working path.
# User settings
[ ! -n "$OUTPUT_FILE_BASENAME" ] && echo "No filename given" && exit 1
if [ -e "$TEMP_FILE" ]; then
  echo "Temp file $TEMP_FILE already exists. We don't want to create a symlink vulnerability here..."
  exit 1
if [ -e "$OUTPUT_FILE" ]; then
  echo "$OUTPUT_FILE already exists."
  exit 1
# page dimensions are in mm
scanimage -d $SCANNER_DEVICE -x 210 -y 297 --mode lineart --resolution $RESOLUTION > $TEMP_FILE

Simple, but effective. I may extend it in the future to also be able to scan into a DjVuDocument file (a file containing both DjVuBitonal and DjVuPhoto segments), but for now, this serves.

    No Comments ( Add comment / trackback )