summaryrefslogtreecommitdiffstats
path: root/ocr-scan
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-04-12 10:45:32 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-04-12 10:45:32 +0200
commitd21a9b6df4cd3a47e540c3cca8203b8f0f53a029 (patch)
treece0dfb9024e5986bafa491c27d4fe1d21c744e59 /ocr-scan
parentefbe42bd1bf65e47cde554c9b4d8c0bde7f22b17 (diff)
downloadbin-d21a9b6df4cd3a47e540c3cca8203b8f0f53a029.tar.gz
bin-d21a9b6df4cd3a47e540c3cca8203b8f0f53a029.tar.xz
add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'ocr-scan')
-rwxr-xr-xocr-scan20
1 files changed, 20 insertions, 0 deletions
diff --git a/ocr-scan b/ocr-scan
new file mode 100755
index 0000000..5e7423f
--- /dev/null
+++ b/ocr-scan
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+jpeg_quality=70
+jpeg_size=1500x1500
+
+time=$(date +%Y-%m-%d_%H%M%S)
+scanimage --resolution 300 -b -x 215 -y 297
+i=1
+while [[ -e "out$i.pnm" ]]; do
+ img="out$i.pnm"
+ newname="$(printf "%s_%03d" "$time" "$i")"
+ unpaper "$img" "unpaper-$img"
+ tesseract "unpaper-$img" "$newname.txt"
+ convert "$img" -normalize -resize $jpeg_size -quality $jpeg_quality "$newname.jpg" && rm "$img" "unpaper-$img"
+ ((i++))
+done
+
+if [[ $1 = "--pdf" ]]; then
+ convert "${time}"_*.jpg -resize $jpeg_size -compress jpeg -quality $jpeg_quality -density 72x72 -repage 595x842 "${time}.pdf" && rm "${time}"_*.jpg
+fi