Use the following ghostscript command:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Summary of -dPDFSETTINGS:

  • -dPDFSETTINGS=/screen lower quality, smaller size. (72 dpi)
  • -dPDFSETTINGS=/ebook for better quality, but slightly larger pdfs. (150 dpi)
  • -dPDFSETTINGS=/prepress output similar to Acrobat Distiller “Prepress Optimized” setting (300 dpi)
  • -dPDFSETTINGS=/printer selects output similar to the Acrobat Distiller “Print Optimized” setting (300 dpi)
  • -dPDFSETTINGS=/default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file

Reference: https://www.ghostscript.com/doc/current/VectorDevices.htm#PSPDF_IN:


brew install ghostscript
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf



This quartz filter compresses the JPEG in a PDF, while maintaining usable resolution. The purpose of this quartz filter is to use it with Apple’s Preview.app to quickly reduce the file size of images in PDF’s while maintaining legibility. macOS does have a built-in filter called “Reduce File Size” that has the same purpose, however this filter is too aggressive and converts images to a resolution that is too low.


To install this filter for the currently logged-in user, run the below command in Terminal:

mkdir -p ~/Library/Filters/ && curl -o ~/Library/Filters/Compress\ Images\ in\ PDF.qfilter https://raw.githubusercontent.com/superman-lopez/compressjpeginpreview/master/Compress%20Images%20in%20PDF.qfilter


After this the filter can be used in Preview.app (and other apps that support quartz filters).

  1. Open the PDF in Preview.app
  2. Select File and Export…
  3. Choose Format to be PDF
  4. Choose Quartz Filter to Compress Images in PDF
  5. Choose your prefered destination and click Save


To uninstall simply run:

rm ~/Library/Filters/Compress\ Images\ in\ PDF.qfilter