Saturday, January 19, 2008

Curious results of various image formats: OS X Preview and PDF

Image compression is a tricky thing. For example, few people know that PNG is by far the best format to use for screen shots; vastly better than JPEG, GIF or (shudder) BMP. (Ok, so Word's mysterious internal format is pretty darned good -- but it's a mystery.)

Storing black and white scanned document images is even odder, however. Consider these results from PDFs generated by my Brother MFC-7820N document scanner (1 page, 300 dpi, b&w). In each case I saved from OS X preview:
  • Original PDF: 132kb
  • PNG: 155kb
  • JPEG 2000 lossless: 296kb
  • JPEG 2000 good quality: 380kb
  • JPEG: 328 kb (artifact can be seen)
  • TIFF zip compression: 220kb
  • TIFF alternative compression: 216kb
A PDF of a scan is simply a wrapper, like TIFF, around some other format. PDF uses different compression depending on the image. A B&W image does very well with ancient run-length compression, so I suspect that's what's being used. I was surprised by how large the TIFFs were -- I think OS X Preview isn't providing the optimal compression for a b&w image.

Interesting that JPEG 2000 lossy is almost 40% larger than lossless for a b&w image. I thought I'd get better results there.

PNG, as always, does very well for lossless compression. A shame they never put any $!#$% metadata into the file specification!

Note that iPhoto will handle all of those image formats except PDF.

No comments: