Skip to content

Instantly share code, notes, and snippets.

@x2q
Created August 26, 2013 14:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x2q/6342108 to your computer and use it in GitHub Desktop.
Save x2q/6342108 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Simple bash script to crop scanned receipts etc.
#
# Dependencies:
# sudo apt-get install unpaper poppler-utils netpbm imagemagick
echo "usage: scan-crop.sh filename.pdf"
pdftoppm -singlefile "$1" /tmp/scan-crop-tmp
unpaper -vv --overwrite /tmp/scan-crop-tmp.ppm /tmp/scan-crop-unpaper.ppm
rm -rf /tmp/scan-crop-tmp.ppm
pnmcrop /tmp/scan-crop-unpaper.ppm > /tmp/scan-crop-unpaper-crop.ppm
rm -rf /tmp/scan-crop-unpaper.ppm
convert /tmp/scan-crop-unpaper-crop.ppm "$1"
rm -rf /tmp/scan-crop-unpaper-crop.ppm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment