Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Created May 6, 2012 09:37
Show Gist options
  • Save qoobaa/2621259 to your computer and use it in GitHub Desktop.
Save qoobaa/2621259 to your computer and use it in GitHub Desktop.
#!/bin/bash
DEVICE=$(scanimage -f "%d%n" | grep epjitsu)
while true; do
rm out*.pnm 2> /dev/null
TIMESTAMP=$(date +%Y%m%d%H%M%S)
scanimage -d $DEVICE --mode Lineart --resolution 300 --source "ADF Duplex" -b 2> /dev/null
if [ -f out1.pnm ]; then
for file in out*.pnm; do
unpaper -dv 5 -ni 15 --dpi 300 -mt 0.05 --overwrite $file $file
convert $file -fuzz 15% -trim -shave 1%x1% -fuzz 15% -trim $file
identify $file | grep 1x1 && rm $file
done
convert -page 2480x3508 -gravity center out*.pnm $TIMESTAMP.pdf
rm out*.pnm
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment