Skip to content

Instantly share code, notes, and snippets.

@anamorph
Created June 23, 2021 07:32
Show Gist options
  • Save anamorph/05899bee05ee4a855efe8b00b14018db to your computer and use it in GitHub Desktop.
Save anamorph/05899bee05ee4a855efe8b00b14018db to your computer and use it in GitHub Desktop.
Creates an alias to compress (quick & dirty) pdfs via the terminal
# pre-reqs:
# ghostscript -> brew install ghostscript
function compresspdf {
INPUT_FILE=$1
FILE_EXTENSION="${INPUT_FILE##*.}"
FILE_NAME="${INPUT_FILE%.*}"
OUTPUT_FILE="$FILE_NAME-compressed.$FILE_EXTENSION"
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dColorImageResolution=150 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$OUTPUT_FILE $INPUT_FILE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment