Last active
August 7, 2022 15:23
-
-
Save fd0/5467790f24b3a00dff85da40edf5701d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
shopt -s dotglob | |
# use bash strict mode | |
set -euo pipefail | |
IFS=$'\n\t' | |
DPI="${DPI:-120}" | |
if [[ "$#" != "2" ]]; then | |
echo "usage: $0 input.pdf output.pdf" | |
exit 2 | |
fi | |
input="$1" | |
output="$2" | |
"gs" -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH \ | |
"-sOutputFile=$output" \ | |
"-dColorImageResolution=$DPI" "-dGrayImageResolution=$DPI" "-dMonoImageResolution=$DPI" "$input" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment