Friday, August 31, 2012

Shrink Preview files without ruining image quality !

Savvy Preview users know they can do some interesting things to PDFs—convert them to black-and-white or sepia tone, increase or decrease their lightness, and more—by selecting File -> Export, then selecting one of the Quartz filters in the resulting dialog box. Reader zpjet is one of those users, but he was never satisfied with results of the Reduce File Size filter (which he'd use when trying to make PDFs small enough to send by e-mail): It made them too small and made the graphics fuzzy.

After a little digging around, he found that these filters are located in the folder /System/Library/Filters, and that they're XML files that are easily edited with TextEdit (or any other text editor). Examining the file for the Reduce File Size filter, he found out why it didn't work for him: Two of the parameters—Compression Quality and ImageSizeMax—were just too low (0.0 and 512, respectively).

So he copied this file to his Desktop, made two copies of it, and then renamed all three: Reduce File Size Good, Reduce File Size Better, and Reduce File Size Best. Then he changed the parameters of each file: 0.25, 0.5 and 0.75 for Compression Quality (respectively) and 842, 1684, and 3508 for ImageSizeMax (ditto). (The first is A4-size at 72dpi, the second A4 at 144dpi, and the third A4 at 300dpi).

Finally, he changed the default string for the Name key at the end of each file—which is what displays in the Export menu—to match its file name. He then created a /Library/Filters folder and put all three edited files in it.

Now, when he opens a picture or PDF in Preview, he has the option of four Reduce File Size filters. So, for example, let's say he's starting with a JPEG of a scanned A4 invoice at 300dpi, and that file is 1.6MB in size. When he exports that to PDF format with the standard Reduce File Size filter, the file goes down to 27KB, but it's quite unusable—fuzzy and hard to read. Using the Good filter produces a file that is much easier to read and only slightly fuzzy, and it weighs in at 80KB. A file produced with the Better filter comes out at 420KB and clear; Best is 600KB and almost as good as the original.

No comments: