# Comparison of Lossless Image Formats

David Barina

► To cite this version:

David Barina. Comparison of Lossless Image Formats. 29th International Conference in Central Europe on Computer Graphics, Visualization and Computer Vision 2021, May 2021, Pilsen, Czech Republic. 29th International Conference in Central Europe on Computer Graphics, Visualization and Computer Vision 2021. hal-03298544

HAL Id: hal-03298544

https://hal.science/hal-03298544

Submitted on 23 Jul 2021

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Comparison of Lossless Image Formats

David Barina

Centre of Excellence IT4Innovations

Faculty of Information Technology

Brno University of Technology

Bozetechova 1/2, Brno

Czech Republic

ibarina@fit.vutbr.cz

## Abstract

In recent years, a bag with image and video compression formats has been torn. However, most of them are focused on lossy compression and only marginally support the lossless mode. In this paper, I will focus on lossless formats and the critical question: "Which one is the most efficient?" It turned out that FLIF is currently the most efficient format for lossless image compression. This finding is in contrast to that FLIF developers stopped its development in favor of JPEG XL.

## Keywords

Lossless Image Compression, PNG, JPEG-LS, JPEG 2000, JPEG XR, WebP, WebP 2, H.265, FLIF, AVIF, JPEG XL

## 1 INTRODUCTION

This paper compares the compression performance of state-of-the-art formats for lossless image compression. It deals with the essential formats from old PNG (1992) to modern JPEG XL (2020). The comparison is performed on three datasets. The first one represents high-resolution photos. The second one consists of artificial images (illustrations). And the third one is made up of scanned pages of books. The motivation for our comparison is to answer the question of which format is most efficient in terms of bits per pixel.

For comparison, we use tools that find the most suitable parameterization of the given compression formats. As far as we know, this makes us different from most published comparisons. Under these conditions, it turns out that the most efficient format for all three datasets is FLIF, closely followed by JPEG XL. This situation is specifically quite interesting because the FLIF development has stopped as JPEG XL supersedes it.

This paper consists of four sections. The Introduction section opens this paper. The Background section discusses the formats and datasets used. The Method and Results section presents our measurements. Finally, the Conclusions section closes the paper.

## 2 BACKGROUND

This section describes the individual lossless image formats in our comparison. We dealt with the following formats: PNG, JPEG-LS, JPEG 2000, JPEG XR, WebP, WebP 2, H.265, FLIF, AVIF, and JPEG XL.

Lossless algorithms [7] usually work on the principle of pixel prediction, the error of which is subject to entropic coding, or a dictionary compression method followed by an entropic encoder. Some formats use a transformation instead of an explicit predictor to decorrelate pixels. Then we talk about residue coding instead of prediction error. However, the principle is the same. The entropic encoder can be a simple (Golomb-Rice encoder) as well as a very specialized arithmetic encoder coupled with context modeling. The paragraphs below describe the individual lossless compression methods in detail.

PNG (1995) [11, 12] is a purely lossless format initially intended to replace the GIF format. It is based on a predictor followed by the dictionary compression method DEFLATE (a combination of LZ77 and Huffman coding), which is usually implemented by the zlib library. Several tools can test different predictors and different parameterizations of the DEFLATE method. This will achieve an even better compression ratio than the zlib at the cost of several orders of magnitude slower compression. The zopflipng tool is used in our comparison with the parameters `-iterations=500 -filters=01234mepb`.

JPEG-LS (1998) [17] is a lossless image format created as a replacement for the lossless JPEG mode, which is inefficient. This compression method consists of a predictor and a subsequent context entropic coder (Golomb-Rice coder). The coder can also encode a sequence of

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.
<figure><img src="image_2.png" /><figcaption>Figure 1: Three datasets used in our comparison. From top: Photos (14 images), Illustrations (10 images), and Books (7 images).</figcaption></figure>

the same pixels by a variant of the RLE method. We use the libjpeg 1.58 library from Thomas Richter for compression with parameters `-ls 0 -c`.

JPEG 2000 [16] is a format based on a discrete wavelet transform [8] followed by a context arithmetic coder. This makes it different from most other lossless compression methods, which are based on prediction error coding. The format allows the choice of lossless or lossy compression paths. Compression is incomparably faster than PNG. There are several implementations of this format, of which we consider the Kakadu commercial library to be the best. Kakadu version 8.0.5 is used for compression with parameters `Cblk={64,64} Stiles={8192,8192} Creversible=yes Clayers=1 Clevels=5`.

JPEG XR (HD Photo) [4] is a 2009 format developed by Microsoft. The format offers a lossless compression mode based on hierarchical discrete cosine transform (DCT) and Huffman coding. As with JPEG 2000, the processing steps are the same for both lossless and lossy coding. Reference software 1.41 with default parameters is used for compression.

WebP [5] is a 2010 compression format developed by Google. The format allows the choice of lossy or lossless compression. The lossless variant is based on a predictor followed by a combination of LZ77 and Huffman coding.

The cwebp reference tool with the `-lossless` parameter is used for compression. WebP 2 is the successor of the WebP image format, currently in development. The cwp2 reference tool with the `-effort 9 -q 100` parameters is used in our comparison.

H.265 (also HEVC) [15] is a 2013 video compression format that supports lossless compression. This format is again based on spatial prediction (without the use of DCT). The format is a classic representative of hybrid video compression. HEIC and BPG image formats are based on their Intra profile. We use the x265 library version 3.4 for compression through the FFmpeg framework with parameters `-c:v libx265 -preset placebo -x265-params lossless=1`.

FLIF [13, 14] is a lossless image format from 2015, strongly inspired by the FFV1 format. The format is based on a predictor and a sophisticated arithmetic encoder MANIAC. As with PNG, the compression ratio can be improved by searching for various parameters. We use the flifcrush tool for this. FLIF development has stopped since FLIF is superseded by JPEG XL.

AVIF is based on the AV1 [6] video format from 2018. Also, this format is a classic representative of hybrid video compression. The format offers both lossy and lossless compression. The format uses a predictive-transform coding scheme for lossless mode, where the
prediction comes from intra-frame reference pixels. The residuals undergo a 2D transform, and then they are entropy coded using arithmetic coding. In comparison, the libavif version 0.8.3 library with the `-l -c aom` parameters (`libaom` 2.0.0) was used.

JPEG XL (2020) [1, 2] is a new image format that supports both lossy and lossless compression. ISO/IEC standard is still under development. Its basic building blocks include transform, prediction, context modeling, and entropy coding (ANS [3] or Huffman coding). We use a reference software version 0.3.3 with `-q 100 -s 9` parameters.

A dataset of 14 high-resolution photographic images [10] in RGB24 format was used for comparison. Thus, the uncompressed image has a bit rate of 24 bpp (bits per pixel). The individual images are shown in Figure 1. The dataset occupies a total of 157 megapixels. We will refer this dataset to it as Photos. We also tested the compression performance on illustrations (artificial images, still 24 bpp). This dataset occupies 10 megapixels. This dataset was composed of images found on Google. We will refer to it as Illustrations. The last dataset used in our paper consists of seven scanned book's pages in 24 bpp and comprises 27 megapixels. The scans were obtained from the collection of the Digital Library of the National Library of the CR. This dataset will be called Books.

## 3 METHOD AND RESULTS

We use two quantities to evaluate the compression efficiency: a bitrate and compression ratio. The bitrate is defined as the number of bits per single image pixel. The compression ratio is defined as the ratio between the uncompressed and compressed file size. The results are shown in Tables 1, 2, and 3.

We evaluated the compression performance of all mentioned image formats on all three datasets. It turned out that the clear winner is the FLIF format. It is even more efficient than the newer JPEG XL. Even though the development of FLIF was stopped in favor of JPEG XL. It is worth noting that an exhaustive search found the FLIF format parameters. JPEG XL has proven to be the second-best choice. WebP 2 is also relatively efficient.

The victory of the FLIF format is also in line with recent results of Rahman *et al*. In their paper [9], the authors compared the compression performance of the lossless JPEG, JPEG 2000, PNG, JPEG-LS, JPEG XR, CALIC, HEIC, AVIF, WebP, and FLIF formats. They concluded that the FLIF is optimal for all types of 24 bpp images, which they evaluated.

Interestingly, all algorithms achieve a compression ratio about three times higher on the Illustrations dataset than on Photos and about two times higher than on Books. It

<table><caption>Table 1: Compression performance on the Photos dataset. The best result in bold.</caption><thead><tr><th>Format</th><th>Bitrate [bpp]</th><th>Compression Ratio</th></tr></thead><tbody><tr><td>PNG</td><td>11.461131</td><td>2.094034 : 1</td></tr><tr><td>JPEG-LS</td><td>10.588847</td><td>2.266535 : 1</td></tr><tr><td>JPEG 2000</td><td>10.620645</td><td>2.259749 : 1</td></tr><tr><td>JPEG XR</td><td>11.575239</td><td>2.073391 : 1</td></tr><tr><td>WebP</td><td>10.619910</td><td>2.259906 : 1</td></tr><tr><td>H.265</td><td>12.460111</td><td>1.926146 : 1</td></tr><tr><td><strong>FLIF</strong></td><td><strong>9.318886</strong></td><td><strong>2.575415 : 1</strong></td></tr><tr><td>AVIF</td><td>12.039541</td><td>1.993431 : 1</td></tr><tr><td>WebP 2</td><td>10.007292</td><td>2.398251 : 1</td></tr><tr><td>JPEG XL</td><td>9.433458</td><td>2.544135 : 1</td></tr></tbody></table>

<table><caption>Table 2: Compression performance on the Illustrations dataset. The best result in bold.</caption><thead><tr><th>Format</th><th>Bitrate [bpp]</th><th>Compression Ratio</th></tr></thead><tbody><tr><td>PNG</td><td>4.628656</td><td>5.185090 : 1</td></tr><tr><td>JPEG-LS</td><td>6.994191</td><td>3.431419 : 1</td></tr><tr><td>JPEG 2000</td><td>6.094012</td><td>3.938292 : 1</td></tr><tr><td>JPEG XR</td><td>8.097638</td><td>2.963827 : 1</td></tr><tr><td>WebP</td><td>4.294325</td><td>5.588771 : 1</td></tr><tr><td>H.265</td><td>7.158238</td><td>3.352780 : 1</td></tr><tr><td><strong>FLIF</strong></td><td><strong>3.394439</strong></td><td><strong>7.070387 : 1</strong></td></tr><tr><td>AVIF</td><td>8.198868</td><td>2.927233 : 1</td></tr><tr><td>WebP 2</td><td>3.621495</td><td>6.627097 : 1</td></tr><tr><td>JPEG XL</td><td>3.473148</td><td>6.910157 : 1</td></tr></tbody></table>

<table><caption>Table 3: Compression performance on the Books dataset. The best result in bold.</caption><thead><tr><th>Format</th><th>Bitrate [bpp]</th><th>Compression Ratio</th></tr></thead><tbody><tr><td>PNG</td><td>8.694597</td><td>2.760334 : 1</td></tr><tr><td>JPEG-LS</td><td>8.394430</td><td>2.859038 : 1</td></tr><tr><td>JPEG 2000</td><td>7.303011</td><td>3.286315 : 1</td></tr><tr><td>JPEG XR</td><td>8.989639</td><td>2.669740 : 1</td></tr><tr><td>WebP</td><td>7.451733</td><td>3.220727 : 1</td></tr><tr><td>H.265</td><td>10.326125</td><td>2.324201 : 1</td></tr><tr><td><strong>FLIF</strong></td><td><strong>6.084763</strong></td><td><strong>3.944278 : 1</strong></td></tr><tr><td>AVIF</td><td>10.398287</td><td>2.308072 : 1</td></tr><tr><td>WebP 2</td><td>6.890983</td><td>3.482812 : 1</td></tr><tr><td>JPEG XL</td><td>6.216347</td><td>3.860788 : 1</td></tr></tbody></table>

also says that the Photos dataset is the hardest to compress for lossless algorithms, whereas the Illustrations are the easiest task.

We thought even compare the computing needs of the individual formats. However, such a comparison would not be fair for two reasons. Firstly, for some formats, we use an exhaustive search for suitable parameters; for others, we do not. Secondly, compression and de-compression ran in parallel on different machines with different hardware.
# 4 CONCLUSIONS

We compared the compression efficiency of state-of-the-art formats for lossless image compression. The comparison was performed on three different datasets. It has been found that the most efficient lossless compression method is the FLIF format. And this despite the fact that its development has stopped since JPEG XL supersedes FLIF. Furthermore, it turned out that the JPEG XL has proven to be the second-best choice. The third in line is the WebP 2 format. It should be noted that some formats are still under development.

## Acknowledgements

This work has been supported by the Technology Agency of the Czech Republic (TA CR) project AI for Traffic and Industry Vision (no. TH04010144) and Progressive Image Processing Algorithms (no. TH04010394).

## REFERENCES

[1] Alakuijala, J., van Asseldonk, R., Boukortt, S., Szabadka, Z., Bruse, M., Comsa, I.-M., Firsching, M., Fischbacher, T., Kliuchnikov, E., Gomez, S., Obryk, R., Potempa, K., Rhatushnyak, A., Sneyers, J., Szabadka, Z., Vandervenne, L., Versari, L., and Wassenberg, J. JPEG XL next-generation image compression architecture and coding tools. In Tescher, A. G. and Ebrahimi, T., editors, *Applications of Digital Image Processing XLII*. SPIE, Sept. 2019. doi: 10.1117/12.2529237.

[2] Alakuijala, J., Boukortt, S., Ebrahimi, T., Kliuchnikov, E., Sneyers, J., Upenik, E., Vandevenne, L., Versari, L., and Wassenberg, J. Benchmarking JPEG XL image compression. In Schelkens, P. and Kozacki, T., editors, *Optics, Photonics and Digital Technologies for Imaging Applications VI*. SPIE, Apr. 2020. doi: 10.1117/12.2556264.

[3] Duda, J., Tahboub, K., Gadgil, N. J., and Delp, E. J. The use of asymmetric numeral systems as an accurate replacement for Huffman coding. In *2015 Picture Coding Symposium (PCS)*. IEEE, May 2015. doi: 10.1109/pcs.2015.7170048.

[4] Dufaux, F., Sullivan, G. J., and Ebrahimi, T. The JPEG XR image coding standard [standards in a nutshell]. *IEEE Signal Processing Magazine*, 26 (6):195-204, Nov. 2009. doi: 10.1109/msp.2009.934187.

[5] Google. Compression techniques, 2020. URL https://developers.google.com/speed/webp/docs/compression.

[6] Han, J., Li, B., Mukherjee, D., Chiang, C.-H., Grange, A., Chen, C., Su, H., Parker, S., Deng, S., Joshi, U., Chen, Y., Wang, Y., Wilkins, P., Xu,

Y., and Bankoski, J. A technical overview of AV1. *Proceedings of the IEEE*, pages 1-28, 2021. doi: 10.1109/jproc.2021.3058584.

[7] Lina J., K. Chapter 16 - lossless image compression. In Bovik, A., editor, *The Essential Guide to Image Processing*, pages 385-419. Academic Press, Boston, 2009. ISBN 978-0-12-374457-9. doi: 10.1016/B978-0-12-374457-9.00016-0.

[8] Mallat, S. *A Wavelet Tour of Signal Processing: The Sparse Way. With contributions from Gabriel Peyre*. Academic Press, 3 edition, 2009. ISBN 9780123743701.

[9] Rahman, M. A., Hamada, M., and Shin, J. The impact of state-of-the-art techniques for lossless still image compression. *Electronics*, 10(3):360, Feb. 2021. doi: 10.3390/electronics10030360.

[10] Rawzor. The new test images, 2015. URL https://imagecompression.info/test_images/.

[11] Roelofs, G. *PNG: The Definitive Guide*. 1999. ISBN 1-56592-542-4.

[12] Salomon, D. *Data Compression: The Complete Reference*. Springer New York, 2004. ISBN 9780387406978.

[13] Sneyers, J. and Wuille, P. FLIF: Free lossless image format based on MANIAC compression. In *2016 IEEE International Conference on Image Processing (ICIP)*. IEEE, Sept. 2016. doi: 10.1109/icip.2016.7532320.

[14] Soferman, N. FLIF, the new lossless image format that outperforms PNG, WebP and BPG, 2015. URL https://cloudinary.com/blog/flif_the_new_lossless_image_format_that_outperforms_png_webp_and_bpg.

[15] Sze, V., Budagavi, M., and Sullivan, G. *High Efficiency Video Coding (HEVC): Algorithms and Architectures*. Integrated Circuits and Systems. Springer International Publishing, 2014. ISBN 9783319068954.

[16] Taubman, D. S. and Marcellin, M. W. *JPEG2000 Image Compression Fundamentals, Standards and Practice*. Springer, 2004. ISBN 978-1-4613-5245-7. doi: 10.1007/978-1-4615-0799-4.

[17] Weinberger, M., Seroussi, G., and Sapiro, G. The LOCO-I lossless image compression algorithm: principles and standardization into JPEG-LS. *IEEE Transactions on Image Processing*, 9(8): 1309-1324, 2000. doi: 10.1109/83.855427.