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. PATH="/usr/bin:/bin:/usr/local/bin" # User settings RESOLUTION="400" SCANNER_DEVICE="plustek" OUTPUT_FILE_BASENAME=$1 OUTPUT_FILE="$OUTPUT_FILE_BASENAME.djvu" TEMP_FILE="/tmp/halfgaars_scanned_image" [ ! -n "$OUTPUT_FILE_BASENAME" ] && "No filename given" && 1 [ -e "$TEMP_FILE" ]; "Temp file $TEMP_FILE already exists. We don't want to create a symlink vulnerability here..." 1 [ -e "$OUTPUT_FILE" ]; "$OUTPUT_FILE already exists." 1 # page dimensions are in mm scanimage -d $SCANNER_DEVICE -x 210 -y 297 --mode lineart --resolution $RESOLUTION > $TEMP_FILE cjb2 -dpi $RESOLUTION $TEMP_FILE $OUTPUT_FILE rm $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.
Recent Comments