#!/usr/bin/env bash # straightpage.sh # Ingests a PXM image, and outputs a PXM image (straightened) with the # same encoding. # $1 = infile # #2 = outfile infile="$1" angle="$(pamtilt -angle=3 "$1")" tmp1=`mktemp` pnmrotate "$angle" "$1" > "$tmp1" # Fill the border with white, to hide copy marks convert "$tmp1" -gravity Center -crop 95%x95+0+0 -background white -flatten -monochrome "$2" # Cleanup rm $tmp1