#!/bin/sh rm -rf ./tmp; # clean previous run # this assumes that the checks are scanned upright, bottom towards left margin on pdf, one per page # this assumes you have scans in ./scans # in pdf format each may have multiple checks, one per page. mkdir ./tmp mkdir ./tmp/scans; # incoming pdf with multiple checks mkdir ./tmp/pngs; # documents for storage prepped # copy incoming to staging area cp ./scans/*pdf ./tmp/scans/; # rip images and resize , crop etc find ./tmp/scans/ -iname "*pdf" -exec pdftohtml -q -c -zoom 10 '{}' \; mv ./tmp/scans/*png ./tmp/pngs/; rm -rf ./tmp/scans # format the pngs for storing mogrify -rotate -90 -chop 0x450 ./tmp/pngs/*png; # Basically all this does is take the pdfs # and put images in tmp/pngs that are sized properly and right side up. # STEP 2 # get images from pngs and turn into micr strip files # ready for gocr # copy to micr rm -rf ./tmp/micr; mkdir ./tmp/micr; cp ./tmp/pngs/*png ./tmp/micr/; mogrify -chop 0x660 ./tmp/micr/*png; # convert the isolated micr for gocr find ./tmp/micr/*png -exec convert '{}' '{}'.pbm \; rename png.pbm pbm ./tmp/micr/*pbm rm ./tmp/micr/*png