]> piware.de Git - bin.git/commitdiff
add scandoc
authorMartin Pitt <martin@piware.de>
Mon, 25 Feb 2008 12:55:34 +0000 (13:55 +0100)
committerMartin Pitt <martin@piware.de>
Mon, 25 Feb 2008 12:55:34 +0000 (13:55 +0100)
scandoc [new file with mode: 0755]

diff --git a/scandoc b/scandoc
new file mode 100755 (executable)
index 0000000..1918261
--- /dev/null
+++ b/scandoc
@@ -0,0 +1,27 @@
+#!/bin/sh -e
+
+name="$1"
+[ -n "$name" ] || {
+    echo "Usage: $0 <output.pdf>"
+    exit 1
+}
+name=$(readlink -f "$name")
+
+D=`mktemp -d`
+cd "$D"
+echo "Output file directory: $D"
+PAGE=0
+while true; do
+    PAGE=$((PAGE+1))
+    scanimage  --resolution 150 --mode Gray -x 210 -y 297 | convert -rotate 180 -modulate 120 -level 30,60% - cur.png
+    FNAME=page`printf '%02i' $PAGE`
+    pngquant 4 < cur.png > $FNAME.png
+    convert $FNAME.png $FNAME.pdf
+    echo "Insert next page and press Enter; q to stop"
+    read x
+    [ "$x" = q ] && break || true
+done
+
+pdfjoin --outfile "$name" page*.pdf
+
+#rm -rf "$D"