26th May 2015
I am using an excellent photo-management suite digiKam, which offers 3 lossless compressed formats for photos versioning and storage: PNG, JPEG 2000, and PGF. I wanted to know which one should I use, which urged me to perform this comparison.
This post is not intended to be an in-depth comparison, but should be sufficient to choose one of the three file formats for your purposes. For more format details and history simply follow the links provided. File formats are reviewed roughly in “historical” order.
- It is lossless.
- It is suitable for photos.
- PNG is more space-efficient in the case of images with many pixels of the same color, such as diagrams/plots (as compared to PGF and JPEG2000). However, PNG photos are almost always larger than lossless PGF/JPEG2000 photos (real photo example: 9.9 MB in PNG, 7.0 MB in JPEG 2000).
- PNG is fairly fast at (en|de)coding.
- PNG is widely supported by web-browsers, image editors, and other software.
- PNG uses CRCs internally for each data block, so if damage occurs only the damaged block(s) should be lost – theoretically. However, in practice, according to the Just One Bit paper (local copy), PNG is actually much less damage-resilient than JPEG 2000.
- It has both lossless and lossy modes. Lossy mode is “better” (perceptually at the same file size) than JPEG.
- Lossless mode is the smallest of all 3 file formats tested.
- JPEG 2000 is slower at (en|de)coding than PGF and PNG.
- JPEG 2000 has several associated ISO and other standards. Software support for JPEG 2000 is not as good as for PNG, but better than for PGF.
- JPEG 2000 has good bit errors resilience (local copy).
- PGF uses the same wavelet-based method as JPEG 2000, so it shares a lot of features with JPEG 2000, including support for lossless and lossy modes, with lossy being “better” than JPEG.
- Lossless mode file is marginally larger than the same image in JPEG 2000 (real photo example: 7.0 MB in JPEG 2000, 7.4 MB in PGF).
- It is much faster at (en|de)coding than JPEG 2000 (this is major difference #1 of 2).
- Software support for PGF is not as good as for JPEG 2000 (this is major difference #2 of 2).
- Being under-appreciated, PGF doesn’t seem to have received any error resilience testing, yet. However, one should expect error resilience similar to that of JPEG 2000, because essentially the same compression method is used (albeit with different “parameters”, resulting in a speed/size trade-off/gain). It is not clear if PGF has any resilience features like JPEG 2000.
Fun fact #1 from the links above: best error resilience was observed for bitmap files.
Fun fact #2: after about 1% of data damage none of the compressed formats is able to reliably reproduce the original image.
I would be happy to use PGF for its speed, compression ratio, and features, but lacking software support is detrimental (in a self-reinforcing manner) to widespread adoption of PGF; being quite similar to the more popular (or better promoted) JPEG 2000, I do not know if PGF will gain sufficient traction to get e.g. browser support.
PNG has very good support, but produces noticeably larger files, and exhibits significantly lower error resilience than JPEG 2000.
So as of today my choice is JPEG 2000 (lossless, with resilience features).