Last active
May 21, 2019 09:26
-
-
Save hyphop/bdd8d31bf8754164b08c0e3f7d947bcc to your computer and use it in GitHub Desktop.
simple script to automate scan process via scanimage (SANE tools) for command line usage
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/sh | |
## hyphop ## | |
# | |
# simple script to automate scan process via scanimage (SANE tools) | |
# for command line usage | |
# | |
# USAGE | |
# scan | |
# | |
[ "$FMT" ] || FMT=jpeg | |
[ "$MODE" ] || MODE=Color | |
[ "$RES" ] || RES=150 | |
[ "$DIR" ] || DIR=~/Pictures/Scan | |
for a in "$@"; do | |
case "$a" in | |
75|150|300|600|1200) | |
shift | |
RES=$a | |
;; | |
*.jpeg|*.jpg) | |
shift | |
FMT=jpeg | |
OUT="$a" | |
DIR= | |
;; | |
*) | |
;; | |
esac | |
done | |
[ -d "$DIR" ] || mkdir -p "$DIR" | |
OUT="$DIR/scan_$(date +%s).$FMT" | |
echo "[i] scan ( $MODE/$RES ) to $DIR | |
> $OUT">&2 | |
scanimage -p --mode $MODE --format $FMT --resolution $RES > "$OUT" | |
display "$OUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment