Skip to content

Instantly share code, notes, and snippets.

@fd0
Last active August 7, 2022 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fd0/5467790f24b3a00dff85da40edf5701d to your computer and use it in GitHub Desktop.
Save fd0/5467790f24b3a00dff85da40edf5701d to your computer and use it in GitHub Desktop.
#!/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