function pdf-shrink --description 'Optimize PDF'

alternative settings:

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)

-dPDFSETTINGS=/ebook (low quality, 150 dpi images)

-dPDFSETTINGS=/printer (high quality, 300 dpi images)

-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)

-dPDFSETTINGS=/default (almost identical to /screen)

https://ghostscript.com/blog/optimizing-pdfs.html

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH \

-dConvertCMYKImagesToRGB \

-dGrayImageFilter=/DCTEncode -dColorImageFilter=/DCTEncode \

-dAutoFilterGrayImages=false -dAutoFilterColorImages=false \

-dDownsampleColorImages=true -dDownsampleGrayImages=true -dDownsampleMonoImages=true \

-dColorImageResolution=150 -dGrayImageResolution=150 -dMonoImageResolution=150 \

-dColorImageDownsampleThreshold=1.1 -dGrayImageDownsampleThreshold=1.1 -dMonoImageDownsampleThreshold=1.1 \

-dPreserveHalftoneInfo=false -dPreserveOverprintSettings=false \

-dTransferFunctionInfo=/Apply -dUCRandBGInfo=/Remove \

-sOutputFile=$argv[2] $argv[1]

end