Last active
July 30, 2022 05:10
-
-
Save garrettheaver/9375deebb0023bfd8937 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# mass deskew scanned files via command line | |
# - requires: ImageMagick and Deskew Tool | |
# - see http://galfar.vevb.net/wp/tag/deskew | |
for d in "$@"; do | |
file=`basename "$d" .pdf` | |
cd "`dirname "$d"`" | |
# extract each page to a jpg | |
convert -density 200 -quality 100 "$d" "$file.%02d.skewed.jpg" | |
#convert -density 200 -quality 100 -rotate -90 "$d" "$file.%02d.skewed.jpg" | |
# deskew all pages | |
for p in `ls *.skewed.jpg`; do | |
deskew-osx -b FFFFFF -o "`basename "$p" .jpg`.deskew.jpg" "$p" | |
done | |
# recombine deskewed jpgs to single pdf | |
mv "$d" "$file.original.pdf" | |
convert *.deskew.jpg -sharpen 5 -quality 70 -page A4 "$d" | |
#convert *.deskew.jpg -density 200 -sharpen 5 -quality 70 -resize "1172x829" "$d" | |
# cleanup | |
rm *.jpg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Verify Github on Galaxy. gid:PtdyBuV2sQBGVzrNzp9kmT