X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=bin%2Fbin%2Fscan.sh;h=a816d3478c1ed2da2a533e4be65b1cde7db4d2c7;hb=2729c2e563e30fff3337b79f7211506dc4087681;hp=f7723c98ee4b0d7ab9a3d3a0d34273d84a704f1d;hpb=5038e694d55cbc12f3126ee3564f96f7febe852f;p=dotfiles.git diff --git a/bin/bin/scan.sh b/bin/bin/scan.sh index f7723c9..a816d34 100755 --- a/bin/bin/scan.sh +++ b/bin/bin/scan.sh @@ -6,28 +6,36 @@ cur=noname.ppm ctr=${1:-1} ctr=$(( $ctr - 1 )) -[ -z "$NEGATIVE" ] && SRC="Flatbed" || SRC="Transparency Adapter" - scan() { resolution=$1 shift - scanimage --format=pnm --mode=Color --depth 16 --progress --resolution=$resolution --source="$SRC" $@ > tmp.ppm + [ -z "$NEGATIVE" ] && src="Flatbed" || src="Transparency Adapter" + [ -z "$NEGATIVE" ] && depth=8 || depth=16 + [ -z "$NEGATIVE" ] && resolution=800 || resolution=1600 + scanimage \ + --format=pnm \ + --mode=Color \ + --depth $depth \ + --progress \ + --resolution=$resolution \ + --source="$src" \ + $@ > tmp.ppm } process() { [ $rotate -eq 0 ] && rotator=cat || rotator="pamflip -rotate$rotate" - $rotator | pnmcrop -closeness=$crop + [ -z "$NEGATIVE" ] && inverter=cat || inverter=pnminvert + $rotator | pnmcrop -closeness=$crop | $inverter } preview() { - [ -z "$NEGATIVE" ] && inverter=cat || inverter=pnminvert - pamdepth 8 < tmp.ppm | pnmscale -w 600 | process | $inverter > preview.ppm + pamdepth 255 < tmp.ppm | pnmscale -w 600 | process > preview.ppm sxiv preview.ppm } do_next() { rotate=180 - [ -z "$NEGATIVE" ] && crop=50 || crop=10 + [ -z "$NEGATIVE" ] && crop=20 || crop=10 ctr=$(( $ctr + 1 )) cur=`printf "%03d.ppm" $ctr` } @@ -35,7 +43,7 @@ do_next() { do_next while : ; do - echo "$cur: (v)iew r(otate) c(rop) (s)can (p)review (n)ext" + echo -n "$cur: (v)iew r(otate) c(rop) (s)can (p)review (n)ext > " read c case $c in v) @@ -54,24 +62,14 @@ while : ; do do_next ;; r) - echo -n Rotate: + echo -n "Rotate (n/r/l/t):" read rotate case $rotate in - n) - rotate=180 - ;; - r) - rotate=90 - ;; - l) - rotate=270 - ;; - t) - rotate=0 - ;; - *) - echo ? - ;; + n) rotate=180 ;; + r) rotate=90 ;; + l) rotate=270 ;; + t) rotate=0 ;; + *) echo ? ;; esac ;; c)