summaryrefslogtreecommitdiff
path: root/unpaperdir.sh
diff options
context:
space:
mode:
Diffstat (limited to 'unpaperdir.sh')
-rw-r--r--unpaperdir.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/unpaperdir.sh b/unpaperdir.sh
new file mode 100644
index 0000000..cf518c2
--- /dev/null
+++ b/unpaperdir.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+usage="Usage: $0 directory
+
+Runs unpaper over all *.binarized.png files in a directory,
+saving the result to *.unpapered.png. The output from unpaper
+is also saved, as *.unpaperlog
+"
+
+test $# -ne 1 && echo "$usage" && exit 1
+find "$1" -type f -name '*.binarized.png' | sort | while read i; do
+ d=`dirname "$i"`
+ b=`basename "$i" .binarized.png | sed 's/.jpg.jpg//g'`
+ echo "Unpapering $i to ${b}.unpapered.png"
+
+ rm -f "$d/$b.unpapered.pbm"
+ unpaper --verbose --no-blackfilter --no-noisefilter --no-blurfilter --no-grayfilter --no-border-scan --no-mask-center --no-deskew --mask-scan-size 10,10 --mask-scan-step 2,2 --mask-scan-threshold 0.2 "$i" "$d/${b}.unpapered.pbm" > "$d/${b}.unpaperlog" 2>&1 || exit 1
+ convert "$d/$b.unpapered.pbm" "$d/$b.unpapered.png"
+ rm -f "$d/$b.unpapered.pbm"
+done