#!/bin/bash
# AO-pdf-shrink
# GPLv3+
#
# Usage:
# AO-pdf-shrink foo.pdf

# Set QUALITY to one of the below:
# screen   -- lower quality, smaller size.
# ebook    -- for better quality, but slightly larger pdfs.
# prepress -- output similar to Acrobat Distiller "Prepress Optimized" setting
# printer  -- selects output similar to the Acrobat Distiller "Print Optimized" setting
# default  -- selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file

QUALITY=screen
OUTPDF="`basename $1 .pdf`-$QUALITY.pdf"

gs									\
	-sDEVICE=pdfwrite						\
	-dCompatibilityLevel=1.4					\
	-dPDFSETTINGS=/$QUALITY						\
	-dNOPAUSE							\
	-dQUIET								\
	-dBATCH								\
	-sOutputFile=$OUTPDF						\
	$1

