Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Last active December 15, 2015 07:49
Show Gist options
  • Save qoobaa/5226690 to your computer and use it in GitHub Desktop.
Save qoobaa/5226690 to your computer and use it in GitHub Desktop.
#!/bin/bash
while true; do
DEVICE=$(scanimage -f "%d%n" | grep epjitsu)
mkdir -p /tmp/scanner
rm /tmp/scanner/out*.pnm 2> /dev/null
TIMESTAMP=$(date +%Y%m%d%H%M%S)
scanimage -d $DEVICE --mode Lineart --resolution 300 --source "ADF Duplex" --batch=/tmp/scanner/out%03d.pnm 2> /dev/null
if [ -f /tmp/scanner/out001.pnm ]; then
for file in /tmp/scanner/out*.pnm; do
# unpaper -dv 5 --dpi 300 -mt 0.05 --overwrite $file $file
convert $file -trim $file
# identify $file | grep 1x1 && rm $file
done
convert -page 2480x3508 -gravity center /tmp/scanner/out*.pnm /home/kuba/Dropbox/Scans/$TIMESTAMP.pdf
rm /tmp/scanner/out*.pnm
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment