Last active
November 27, 2022 12:21
-
-
Save coderbyheart/43107a1c9c1f035ab7dd2a2576c032c3 to your computer and use it in GitHub Desktop.
Normalize PDF scans with handwritten notes and color markings
This file contains 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
#!/usr/bin/env zsh | |
set -x | |
set -e | |
filename=$(basename -- "$1") | |
name="${filename%.*}" | |
# from https://poppler.freedesktop.org/ | |
pdfimages -j -p $1 $name | |
for image in `find -type f -name $name-\*.jpg`; | |
do | |
imageName="${image%.*}" | |
echo $image | |
echo $imageName | |
# convert from https://imagemagick.org | |
# https://imagemagick.org/script/command-line-options.php | |
convert -normalize -modulate 100,250,100 $image $imageName.modified.jpg | |
rm $image | |
done | |
# https://gitlab.mister-muffin.de/josch/img2pdf | |
img2pdf $name-*.modified.jpg -o $name.processed.pdf | |
rm $name-*.modified.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment