Created
September 4, 2018 10:08
-
-
Save glenux/5b68bddf2ccb0763f75904fc800e0419 to your computer and use it in GitHub Desktop.
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/sh | |
set -e | |
set -u | |
INPUT="${1:-}" | |
OUTPUT="${2:-}" | |
if [ -z "$INPUT" ]; then | |
echo "ERROR: please give a input file name" | |
exit 1 | |
fi | |
if [ -z "$OUTPUT" ]; then | |
OUTPUT="$(echo "$INPUT" |sed -e 's/\.pdf$/.optim.pdf/')" | |
fi | |
# either screen, print or ebook | |
QUALITY="${3:-screen}" | |
case "$QUALITY" in | |
print|screen|ebook) ;; | |
*) echo "ERROR: quality must be one of screen|ebook|print" | |
exit 1 | |
esac | |
gs -sDEVICE=pdfwrite \ | |
-dCompatibilityLevel=1.4 \ | |
"-dPDFSETTINGS=/$QUALITY" \ | |
-dNOPAUSE \ | |
-dQUIET \ | |
-dBATCH \ | |
"-sOutputFile=$OUTPUT" \ | |
"$INPUT" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment