From e010d0b02bfa6525dc81738f039cb2911b21cec3 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 15 Jul 2019 16:10:44 +0100 Subject: Add unpaperdir.sh --- unpaperdir.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 unpaperdir.sh (limited to 'unpaperdir.sh') 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 -- cgit v1.2.1-24-ge1ad