Script to scan a document
For a long time I used a simple bash script to scan my paper documents, something easy, a single command just to do that.
Today I’m switching to a gscan2pdf which is a really good and fast tool to take a lot of paper and merge them into a single or multiple pdf files. It is not a command line, but its gtk interface is not one of those 20 clicks just to do the same thing over and over .
Here the old scandoc script.
#!/bin/bash
RUNME=scanimage;
USBDEV=$(lsusb -d 04a9:220d | sed -e "s/^Bus \([0-9]\{3\}\) Device \([0-9]\{3\}\).*/\1:\2/");
echo "Device USB: $USBDEV";
DEVICE="plustek:libusb:$USBDEV";
# microtek scanner
#OPTIONS="--resolution 96"
# canon lide scanner 100 dpi
OPTIONS="--resolution 100 -x 215 -y 297"
# 300 dpi res.
# OPTIONS="--resolution 300 -x 215 -y 297"
# Program to display the image
VISUALIZER=feh
if [ ! $1 ];
then
$1 = out;
fi
if [ -e $1.jpg ];
then
echo 'File <'$1'.jpg> exist... exiting !!!';
exit 0;
fi
echo $RUNME -d $DEVICE $OPTIONS $1;
$RUNME -d $DEVICE $OPTIONS |convert pnm:- jpeg:$1.jpg
$VISUALIZER $1.jpg
exit 0