111

Background

I want to decrease size of the .pdf filled with images. In Preview in can be dome through Export and set Quartz Filter-> Reduce File Size before saving.

Preview-Export

Problem

The file indeed decreased from ~30MB to 0.37MB.

But the result has such poor quality that images are barely readable.

Question

I saw an examples of using Image Magic to achieve that - but can it be done by Preview without any external software?

1

10 Answers 10

135

The problem is - the default filter used during conversion has very low conversion settings.

Thankfully, a custom filter can be added.

Adding custom filter step by step

  1. Create new directory (if you don't have it) - /Library/Filters
  2. Add there new filter file with unique filter - f.e. Reduce Size with good quality.qfilter
  3. The file should contain XML with new filter - you can base on the /System/Library/Filters/Reduce File Size.qfilter file or use my below example. Change compression setting, image size and add unique display name for your filter.

Filter file structure/example

I marked key settings by comments.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Domains</key>
    <dict>
        <key>Applications</key>
        <true/>
        <key>Printing</key>
        <true/>
    </dict>
    <key>FilterData</key>
    <dict>
        <key>ColorSettings</key>
        <dict>
            <key>DocumentColorSettings</key>
            <dict>
                <key>CustomLHSCorrection</key>
                <array>
                    <integer>8</integer>
                    <integer>8</integer>
                    <integer>8</integer>
                </array>
            </dict>
            <key>ImageSettings</key>
            <dict>
                <key>Compression Quality</key>
    <!-- ====== Set your custom quality <0,1> ======= -->
                <real>0.75</real>
                <key>ImageCompression</key>
                <string>ImageJPEGCompress</string>
                <key>ImageScaleSettings</key>
                <dict>
                    <key>ImageScaleFactor</key>
    <!-- ====== Set your scale factor <0,1> ======= -->                 
                    <real>0.75</real>
                    <key>ImageScaleInterpolate</key>
                    <true/>
    <!-- ====== Set what sizes your images can reach ======= -->                    
                    <key>ImageSizeMax</key>
                    <integer>1684</integer>
                    <key>ImageSizeMin</key>
                    <integer>1200</integer>
                </dict>
            </dict>
        </dict>
    </dict>
    <key>FilterType</key>
    <integer>1</integer>
    <key>Name</key>
<!-- ====== Set unique display name for your filter ======= -->
    <string>Reduce Size Good Quality</string>
</dict>
</plist>

Result

Select your new filter when exporting file.

enter image description here


Helpful articles:

11
  • 15
    I regret that I have but one upvote to give... Commented Aug 5, 2020 at 21:09
  • 4
    You can also put it in ~/Library/Filters so no sudo needed, at least on macOS 11.6. Thank you, this was so helpful. Commented Oct 26, 2021 at 0:21
  • 3
    This no longer works because even as root you still get "Operation not permitted" when trying to add or edit anything in the /System/... directory
    – Anna T
    Commented Nov 24, 2021 at 16:25
  • 2
    The "smaller" file ended up 10 times bigger.... Commented Feb 25, 2022 at 6:57
  • 2
    For me ImageSizeMax 3368 and ImageSizeMin 2400 worked best. It reduced size by 2.5x times without visible quality loss. Also, it is recommended to use ~/Library/Filters folder so you don't use root account which is not necessary here.
    – laimison
    Commented Jan 29 at 23:14
108

Use Apple's built-in ColorSync Utility to create a custom filter.

You can create your own Filter to reduce the image data size in the PDF, using Apple's built-in ColorSync Utility.

Click the Filters tab in the toolbar. Then click + at the bottom of the window, to add a new filter. The click the cogwheel or dropdown menu on the right-hand side of your filter.

enter image description here

Then under "Add Image Effects Components", choose "Color Image Sampling", and optionally Image Compression.

enter image description here

Note that you can't modify the existing system ones, but you can duplicate and modify them.

Then select the Filter in Preview's Export:

enter image description here

(NB: For some reason "Export As PDF" doesn't show the Filters, but Export, choosing PDF as the file format, does.)

9
  • 1
    It worked like a charm! It worth the note, the original filter can't be modified, one has to duplicate the original filter, name it, and only then you can change it.
    – Farside
    Commented Nov 28, 2019 at 12:54
  • (Rename by double-clicking name in ColorSync Utility list.) The resulting filter ends up in ~/Library/Filters (in Catalina, at least); move it to /System/Library/Filters/ if for some reason it needs to be available system-wide.
    – JLundell
    Commented Dec 6, 2019 at 15:08
  • 2
    @JLundell You can't write to /System. You can stick it in /Library/Filters for all users.
    – benwiggy
    Commented Dec 6, 2019 at 16:04
  • Even simplier than editing a XML file ! Thanks
    – webofmars
    Commented Mar 30, 2020 at 11:24
  • 1
    @KenShirriff Open a New Window, if necessary, and click on the Filters Tab.
    – benwiggy
    Commented Apr 19, 2021 at 17:58
19

Easy Way


ColorSync Utility

open 'color sync utility' and choose Filters and Duplicate Filter

enter image description here

Set resolutions and Image Compression as 'Uncompressed'

enter image description here

Go to Export menu. (NOT Export as PDF)

enter image description here

3
  • 1
    How does this add to the answers already provided?
    – benwiggy
    Commented Aug 20, 2020 at 17:26
  • the answer did not mention Uncompress Mode. and no screen shot
    – Jin Lim
    Commented Aug 20, 2020 at 20:10
  • 1
    Upvoted. The screenshots might only be a minor addition, but no other answer so far mentioned how to set up filters for uncompressed images, which is crucial. Commented Sep 29, 2020 at 11:25
12

You can use ImageMagick to reduce the size of a PDF by lowering its resolution.

Install with brew install imagemagick, then run:

convert -density 72 oldfile.pdf new.pdf

where 72 is the target DPI.

6

Preview is very limited in its capabilities.

(Although @michalczukm's answer might well be worth a try for simple documents, e.g. those PDFs with not much structure, without Bookmarks. Also: while you may not visually discern any quality loss, it is still a lossy procedure, but with less aggressive settings then the original Quartz-filter.)

Instead of Image Magick or Preview I suggest to try:

  • Adobe Acrobat (expensive)

or the libre/free

  • GhostScript with the following parameters:
    gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dCompatibilityLevel=1.7 -dNOPAUSE -dQUIET -dPDFSETTINGS=/prepress -sOutputFile=Name_of_Outputfile.pdf To_Reduce_Input.pdf

You may play with these settings. Those given here should not perform any lossy conversions or strip away important document structures. Meaning: most of the time the savings gained might be very good, but sometimes the file size even increases.

Ghostscript is available through a number of venues for macOS. The related muPDF is even available on the App Store.

If you created the PDF yourself then it would be obviously best to losslessly reduce the images before including them into the document (the PDF). Adjusting the image size in terms of pixel count/resolution appropriate for the intended output medium might produce the biggest savings.

3
  • 1
    the usage of ghostscript looks great for larger and more complex scenarios. For simple documents (that was my case) filter was quick to use and good enought. PS notice that both question and first answer are mine :) Commented Sep 7, 2017 at 9:56
  • muPDF is only on the iOS App Store, not the Mac App Store.
    – benwiggy
    Commented May 10, 2021 at 18:50
  • The following post from GhostScript Official Blog helps me a lot ghostscript.com/blog/optimizing-pdfs.html I managed to reduce a 900MB ocred-PDF file to around 190MB with very little loss of readability.
    – pimgeek
    Commented Apr 24 at 13:58
6

As per michalczukm answer, a quartz filter can solve this. I had created my own and shared it on Github. You can install it easily with a single command line. It doesn't install any software, just the quartz filter only.

https://github.com/superman-lopez/compressjpeginpreview

Install

Run below code in your 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

Usage

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
1
  • 1
    This works pretty well, thanks! Commented Aug 29, 2023 at 17:16
4

You can use this website: https://smallpdf.com/compress-pdf to shrink PDFs to a really small size. The PDF quality is still really good even after the compression.

2
  • Nice platform, but unfortunately timed out for me 4k page PDF (3+ GB) > "Compressing your PDF File took too long. Maximum compression time is currently limited to 10 Minutes."
    – philshem
    Commented Dec 4, 2018 at 10:17
  • I've used that briefly so far in trial mode. Bulk-compresses PDFs in Finder from service menu, save a lot of space (in pro mode). Quite convenient! Prices are $11.60/month or $105/year. Commented Nov 25, 2019 at 15:18
3

This is for anyone who is in the same boat as I was. I had a PDF of handwritten annotations on a book exported from Goodnotes. The Quartz Filter method didn't work for me, even when I applied a custom filter with aggressive settings. This makes me think that the filter is only applied to images in the PDF. In my case, the most aggressive filter reduced a PDF of size 104 MB to 103 MB!

Using Automator to Reduce PDF Size

Note: This method works by converting pages in your PDF to compressed JPEGs and then stitching them back into a PDF, so other PDF data such as bookmarks and notes will be stripped.

  • Open Automator.
  • Go to File > New and Choose Workflow.
  • Create the Workflow as follows.
    • In the left pane, look for Ask for Finder Items and drag it to the right pane.
    • Next, add Render PDF Pages as Images and set the Compression and Resolution of the JPEGs.
    • Finally, add New PDF from Images.
  • Click on Run (top-right), choose your PDF and wait for Automator to do its job.

In my case, this reduced the file size to 10 MB.

Here's a screenshot of my Workflow:

Workflow Screenshot

This answer is based on this answer on Apple communities.

2
  • Doesn’t this decrease quality of the PDF?
    – bmike
    Commented Dec 30, 2020 at 12:31
  • The JPEG compression level and Resolution can be set. It's not lossless but that's true for the Quartz Filter method too. Commented Dec 30, 2020 at 13:03
0

For someone who is not bothered by losing a bit of quality and if it is a single page document

These are the steps

  1. open the large size pdf, File -> Export -> Format (change to JPEG-2000) -> Quality (change to lossless) -> Resolution (change to 200 pixels/inch) -> Save

  2. Now open the JPEG and export it as PDF.

For my file it reduced from 4MB to 700KB with negligible loss of quality.

-1

If you have a pdf which is version 1.6 or 1.7, you can use the duplicate setting in Preview. Preview will save the file as a 1.4 pdf and save about 50% in file size. As far as I can tell there is no loss of quality. No need to use the export - reduced file size unless you want further savings.

4
  • That might work, OK, for some documents intended for print. But the reasoning is doubtful. Usually increasing PDF version allows for better compression etc. Do you realise that using Preview in this way is lossy, e.g. re: document structure: you'll loose bookmarks for example? Commented May 17, 2018 at 22:23
  • I'm just describing some findings from working with Preview and PDFs. I don't understand why this works the way it does but that's what I learned..
    – Natsfan
    Commented May 18, 2018 at 0:15
  • Well i cant get this to repeat with a newer version of preview. i don;t know what happened. I'm sure my earlier analysis was correct.
    – Natsfan
    Commented May 18, 2018 at 1:31
  • I'm confident your observation was correct (the "explanation" likely not). That's why this A is still OK & the method worth a shot. There are quite a few very awful PDFs out there. Even from really big publishers. (Have you tried with the same PDFs but with newer Preview?) Since the PDF-spec itself is a mess: Apart from ensuring to control creation from the start, the "best" method has to be tried out, almost each time… Commented May 18, 2018 at 1:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .