Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, PHP, and whatever else I happen to feel like hacking at.

Quality reduced file size in Mac OS X Preview

Jerry Stratton, January 29, 2006

ColorSync Utility Icon

ColorSync makes Quartz filters.

If you use the print to PDF feature in Mac OS X, you have probably noticed that it can create some really large PDF files. This is fine as long as you are copying them to CD or DVD, but if you’re putting them on the web or sending them through e-mail, they can really cause havoc on both ends.

If you open the PDF in Preview, you can reduce the file size by doing a “Save As...” and choosing, appropriately, Reduce File Size from the Quartz Filter menu. Often, that will be fine. But the way that it reduces the file size is by saving all images as JPEGs of middle quality. Sometimes that quality will not be enough.

I just finished a Persistence of Vision tutorial, and because it’s a tutorial on using a 3-D raytracer it was full of images. The PDF file was nearly 20 megabytes. After saving it with Reduce File Size, it was down to under one megabyte... but the quality of the images was so bad that they didn’t serve to illustrate the concepts in the text.

It was obvious what was happening, and I knew that when saving JPEG files you are allowed to trade off low file size with increased quality. But there was no slider available in the Quartz Filter menu to increase the quality of the image.

The answer, it turns out, is in ColorSync Utility in the Utilities folder off of the Applications folder. ColorSync Utility can create new Quartz filters. Open up ColorSync Utility and switch to the “Filters” pane. This will list all of the filters that you currently have available.

  1. In the lower left, click on the “+” button. This creates a new filter.
  2. Give the filter a name, and press return.
  3. To the right of the filter’s name, choose the down arrow. A menu will pop up.
  4. From the pop-up menu, choose “Add Image Effects Component”, and from that menu choose “Image Compression”.
  5. Adjust the image compression Mode to JPEG.
  6. Adjust the image compression quality however you prefer.
  7. The next time you use Preview to “Save As...”, you'll have a new option under Quartz filters.
Quartz Filters in ColorSync Utility

I’ve created a Reduced File Size High Quality and Mid-Quality as custom Quartz filters.

With the quality slider three quarters over, the file size dropped to 7.7 megabytes. This is quite a bit larger than with the slider half-way over, but not nearly the 20 megabytes of the original. And quality became a lot higher.

Filter while printing

You can also filter while printing, avoiding the need to re-open the PDF in Preview. When you go to print, pull down the menu just below “Presets” that usually says “Copies & Pages”. Choose “ColorSync”. Then choose the Quartz filter that you want. Once you’ve chosen it, you can also pull down the Presets menu and do a “Save As...” to remember these settings.

February 16, 2012: Quality compressed PDFs in Mac OS X Lion
Lion Preview Export

Save As… has been renamed to Export in Lion’s Preview.

I’ve verified that these instructions for using Preview to compress PDFs continue to work in Mac OS X Lion.

One minor problem is that the last paragraph—that you can even “filter while printing” without using Preview is no longer true, but it wasn’t true in Snow Leopard either. I can’t remember if it worked in Leopard or if it last worked in Tiger.

I took some screenshots but haven’t included them here; they really are exactly the same as when I wrote those instructions. The only real difference is that in Lion, “Save As…” has been renamed “Export…”.

The main issue, as Vinnie pointed out in the comments is that after you create the filter it doesn’t automatically show up in Preview’s list of Quartz filters. Either ColorSync or Preview is working from the wrong folder.

ColorSync saves your filters in your personal “Filters” folder under your “Library”. But Preview looks in “PDF Services” for the filters. Copy or move the new filter from your Library’s “Filters” folder to your Library’s “PDF Services” folder. If you want to make the filter available to everyone who uses your Mac, put it in the main “/Library/PDF Services” folder instead. Note that Lion has hidden the Library folder, so you’ll need to use the “Go” menu and “Go to folder…” to go to your “Library” folder, and also to go to the “/Library”, depending on whether you are making it available for yourself or for everyone.

Further note that Preview in Lion, but not Snow Leopard, (sometimes? always?) has problems finding Quartz filters inside your own PDF Services folder, so you may have to always put it in the main Library’s PDF Services folder instead. Oddly, the Print dialog doesn’t have any problem with this, only Preview.

This will work in Snow Leopard as well—and will sort of bring back the ability to use the filter directly while printing to PDF. The filters will be available under the PDF menu; on choosing a Quartz filter, it will immediately save the current document as a PDF. The Mac doesn’t seem to ask for a filename, and just deposits it on the Desktop, though some of that may have to do with settings on my computer.

  1. <- Simple POV
  2. Hijacking iTunes ->