Created
April 22, 2013 17:04
-
-
Save hrpunio/5436746 to your computer and use it in GitHub Desktop.
Scan 1 page with desktop scanner (without running Xsane)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# scan documents to PDF | |
# t.przechlewski // 2013 | |
# | |
XSIZE=210 | |
YSIZE=297 | |
MODE="Gr" | |
RESOLUTION=150 # try "lin", "bin", "gr", or "col" | |
USAGE="*** $0 -x XSIZE -y YSIZE -mode [lin|gr|col] -r RESOLUTION out-file.pnm | |
*** Domyślnie: XSIZE/YSIZE=A4, mode=Gr, RESOLUTION=150 | |
*** Rozszerzenie .pnm jest opcjonalne" | |
while test $# -gt 0; do | |
case "$1" in | |
-help|--help|-h) echo "$USAGE"; exit 0;; | |
-x) shift; XSIZE="$1";; | |
-x*) XSIZE="`echo :$1 | sed 's/^:-x//'`";; | |
-y) shift; YSIZE="$1";; | |
-y*) YSIZE="`echo :$1 | sed 's/^:-y//'`";; | |
## ## ## | |
-mode) shift; MODE="$1";; | |
-mode*) MODE="`echo :$1 | sed 's/^:-mode//'`";; | |
## ## ## | |
-r) shift; RESOLUTION="$1";; | |
-r*) RESOLUTION="`echo :$1 | sed 's/^:-r//'`";; | |
*) OUT_FILE="$1";; | |
esac | |
shift | |
done | |
## ## ## | |
if [ "$OUT_FILE" = "" ] ; then echo "$USAGE"; exit ; fi | |
## podano nazwę z rozszerzeniem: | |
if [ ${OUT_FILE: -4} == ".pnm" ] ; then | |
: | |
else | |
OUT_FILE="$OUT_FILE.pnm" | |
fi | |
## ## ## | |
scanimage -x $XSIZE -y $YSIZE --mode $MODE -p --resolution $RESOLUTION > "$OUT_FILE" | |
/usr/bin/beep -f 500 | |
PDF_FILE="`basename $OUT_FILE .pnm`.pdf" | |
if [ -f $OUT_FILE ] ; then | |
echo "** konwertuję $OUT_FILE na $PDF_FILE" ; | |
convert $OUT_FILE -page A4 $PDF_FILE | |
else | |
echo "** Plik $OUT_FILE nie istnieje" ; | |
fi | |
## ## ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment