High-quality compression & format conversion made simple!

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

In the digital age, image quality and compression efficiency have become critical issues. This article compares four mainstream lossless image formats: PNG, WebP, AVIF, and JPEG XL, exploring their advantages and disadvantages in terms of compression efficiency, encoding speed, and application scenarios.

What is Lossless Compression?

Lossless compression is a method of reducing file size without losing any data. Common lossless compression formats include ZIP and RAR. In web environments, GZIP compression is typically used to shrink JavaScript and CSS files. In the field of image compression, PNG is a well-known lossless format.


The alternative to lossless compression is lossy compression, which is often used when compressing photos. JPEG is perhaps the most famous lossy image format. Lossy compression discards some details in the image, resulting in a significant reduction in file size. Since large photos are too big to transmit and store, sacrificing some quality is usually a good trade-off.

When to Use Lossless Compression?

While lossy image formats like JPEG and WebP work well for photos, they are less suitable for graphics. Compression artifacts (such as blockiness and blurriness) are easily noticeable on such images.

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

Lossless image compression performs best when handling images with large areas of continuous color, such as logos, screenshots, charts, and graphics. These types of images often yield smaller file sizes with lossless compression algorithms while maintaining high quality.

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

Example of effective lossless compression: A recycling symbol in PNG format takes up 3 KB. A JPEG of the same file size exhibits obvious compression artifacts. A JPEG with the highest quality looks identical to the PNG but is eight times larger in size.

Format Introductions

PNG

PNG (Portable Network Graphics) is an established lossless image format first released in 1996. It emerged as a replacement for the GIF format, offering advantages such as support for 24-bit color and transparent channels. PNG uses the DEFLATE compression algorithm and is compatible with various compression optimization tools like PNGOUT, OptiPNG, and OxiPNG. All browsers support the PNG format.

WebP

Google introduced WebP in 2010 as a lossy image format based on the VP8 video codec. WebP 0.3, released in 2012, added a lossless mode unrelated to the VP8 codec. Lossy WebP is limited to 4:2:0 chroma subsampling, which discards some color information, while lossless WebP retains all original image data. Until 2020, Apple’s Safari browser was the only major browser resisting WebP. However, by 2021, all major browsers supported WebP.

AVIF

AVIF stands for AV1 Image File Format. It is a new image format based on the AV1 video codec, featuring advanced capabilities such as support for high bit depth and HDR. The format supports both lossless and lossy compression. The latest version of Google Chrome supports AVIF, and it can be enabled in Firefox using a configuration flag.

JPEG XL

JPEG XL is an upcoming new image format developed by combining two existing image formats: Pik (developed by Google) and FUIF (Free Universal Image Format, developed by Cloudinary). Chrome and Firefox support JPEG XL but do not enable it by default; support must be activated using a feature flag.

Comparison Results

File Size & Encoding Speed Summary

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL

Test results show that most modern lossless image formats (e.g., WebP and JPEG XL) offer significant efficiency improvements over optimized PNGs.


PNG: Optimizing PNGs with OxiPNG can reduce their size slightly by approximately 12%, which is not a substantial difference. OxiPNG is very fast, processing an image in about 700 milliseconds. Combining the Zopfli setting with OxiPNG makes optimization extremely slow, averaging around 208 seconds (or three and a half minutes), with the resulting files being only about 18% smaller than the original PNG. Using Zopfli compression is not recommended due to its excessive time consumption and minimal size reduction.


WebP: Newer formats like WebP or JPEG XL generate much smaller files with encoding times that are a fraction of Zopfli’s. Given the minimal gains and high time costs of PNG optimization, optimizing PNG files may not be worthwhile if modern formats are available. Even unoptimized, PNG remains a decent choice for source images due to its compatibility with most software, such as image editors and content management systems. You can convert original PNG files to more efficient formats before displaying them to end-users. PNG also serves as a useful fallback for clients that cannot display modern formats (e.g., some email clients and older browsers).

WebP Evaluation: WebP is an excellent choice for lossless images, easily outperforming PNG in compression efficiency with an average file size reduction of 41%. It also enjoys widespread support across web browsers and other software. WebP files encode quickly, taking approximately 3 seconds to compress.


AVIF Evaluation: AVIF’s performance is somewhat disappointing. While lossy AVIF does take a long time to compress, it offers excellent compression results compared to JPEG and WebP. Unfortunately, this is not the case for lossless AVIF. In lossless mode, encoding AVIF files takes an average of 30 seconds, but the results are underwhelming compared to competing formats, with an average size reduction of only about 20%. The resulting files are comparable in size to OxiPNG with Zopfli but significantly larger than WebP or JPEG XL. For AVIF, sticking to its strengths in lossy compression is recommended.


JPEG XL Evaluation: JPEG XL, as a newer format, leaves a strong impression. It achieves an average file size reduction of about 48%, slightly outperforming WebP. At the 75th percentile, JPEG XL has an edge over WebP, meaning it performs better when compressing complex, hard-to-compress images. However, its compatibility remains a challenge.

Comparison of Lossless Image Formats: PNG, WebP, AVIF, and JPEG XL