Created
October 30, 2025 16:18
-
-
Save rotaliator/f3708e804984a0ca006f302da99bb77d 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
| #!/usr/bin/env bash | |
| set -e | |
| if [ "$#" -lt 2 ]; then | |
| echo "Usage: $0 input.pdf output.pdf" | |
| exit 1 | |
| fi | |
| INPUT_PDF=$1 | |
| OUTPUT_PDF=$2 | |
| echo "Extracting JPG's from PDF" | |
| pdfimages -all $INPUT_PDF extracted | |
| echo "Cleaning JPG's" | |
| convert extracted-*.jpg -colorspace Gray -normalize -level 20%,80% -brightness-contrast 10x40 -set filename:fn 'clean-%[basename]' '%[filename:fn].jpg' | |
| echo "Creating output PDF..." | |
| convert clean-*.jpg $OUTPUT_PDF | |
| echo "...done" | |
| echo "Cleaning temporary files..." | |
| rm extracted-*.jpg | |
| rm clean-extracted-*.jpg | |
| echo "All done :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment