Skip to content

Instantly share code, notes, and snippets.

@phrawzty
Created February 10, 2021 18:10
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 phrawzty/d4f82b41dc20f0ac1cf761ee691cb13f to your computer and use it in GitHub Desktop.
Save phrawzty/d4f82b41dc20f0ac1cf761ee691cb13f to your computer and use it in GitHub Desktop.
Make a big pdf smaller from the commandline using ghostscript
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <filename.pdf> [filename2.pdf …]"
exit `false`
fi
gs=`which gs`
if [ $? -ne 0 ]; then
echo "gs not found."
exit `false`
fi
for file in $@; do
if [ ! -f $file ]; then
echo "$file not found."
else
$gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=SMALL__$file $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment