Created
February 10, 2021 18:10
-
-
Save phrawzty/d4f82b41dc20f0ac1cf761ee691cb13f to your computer and use it in GitHub Desktop.
Make a big pdf smaller from the commandline using ghostscript
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
#!/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