Skip to content

Instantly share code, notes, and snippets.

@coderbyheart
Last active November 27, 2022 12:21
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 coderbyheart/43107a1c9c1f035ab7dd2a2576c032c3 to your computer and use it in GitHub Desktop.
Save coderbyheart/43107a1c9c1f035ab7dd2a2576c032c3 to your computer and use it in GitHub Desktop.
Normalize PDF scans with handwritten notes and color markings
#!/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