This test only focuses on lossless compression.
First test case:
Firstly, I wanted to check some images of medium-to-hard compression difficulty, so I figured game screenshots was a good source. The screenshots I found online already had compression artifacts in them (even PNGs), so I ended up making some myself just to give the algorithms a chance to shine. (And it turns out I haven't gotten many games the past few years

, so AoE II and C&C remastered it is, along with some Unigine benchmarks.)
All very large images; 3480x2160, 24bpp.
Compression comparison:
| PNG | OptiPNG | WebP | AVIF | JPEG XL |
Image1 - AoE II Rem. | 17078937 | 15124685 | 13798112 | 16122545 | 16114673 |
Image2 - C&C Rem. | 13867871 | 13777863 | 10791384 | 10307663 | 10001043 |
Image3 - Unigine Sup. | 11205027 | 11134088 | 9541984 | 8356204 | 7839086 |
Image4 - Unigine Valley | 7586407 | 7235039 | 5951946 | 5407012 | 5243487 |
Image5 - Unigine Valley | 10314065 | 10111339 | 8069364 | 7709303 | 6860860 |
| | 4.44% | 19.82% | 20.23% | 23.30% |
Then I compared compression speed (converting from PNG):
| OptiPNG | WebP | AVIF | JPEG XL |
Image1 | 165.083 s | 6.21 s | 5.405 s | 21.335 s |
Image2 | 180.848 s | 4.543 s | 5.153 s | 15.701 s |
Image3 | 237.349 s | 4.85 s | 5.612 s | 14.588 s |
Image4 | 426.164 s | 4.706 s | 12.871 s | 8.996 s |
Image5 | 294.696 s | 4.797 s | 5.101 s | 13.095 s |
Tested on a Ryzen 9 5900X 12C/24T 3.7/4.8 GHz stock. All using CLI tools:
cwebp,
avifenc,
cjxl and
optipng. Most tools seemed to spawn threads, but didn't manage to saturate the CPU more than ~4-4.3x a single core.
Then when validating my results I discovered to my big disappointment that quality level 100 (which is claimed to be lossless) is just very close to lossless, but only the parameter --lossless truly is, so rerunning avifenc with that results in images as big as PNG.
So that's a complete failure on AVIF in my opinion. I validated the results using image-magick to give me the pixel differences.
Second test case:
I also did a second test case, where I just picked a bunch of assets from my old projects; backgrounds, sprites and GUI elements, mostly simpler stuff, things we should expect PNG to compress very well already. The intention here is to emulate a use case for anyone hosting a website, making an app or a desktop application/game, where there typically are some assets that needs to be lossless. I'm not going to show individual files here, this is just to give an indication.
Aggregated results:
OptiPNG: | WebP: | AVIF: | JPEG XL: |
8.33% | 37.31% | -2.46% | 33.95% |
Keeping in mind once again the results for AVIF here are invalid, but I included it to showcase how surprisingly bad it performs in simpler images. Looking at individual images, it actually performed worse the "simpler" the image is.
Most impressive here is WebP, which managed to compress already heavily compressed PNGs much further. I observed up to 93% reduction in size vs. PNG. Also worth noting is that especially for the simplest images (typically GUI elements), where is typically where we see OptiPNG help a lot, you'll get around 30-40% compression on top of what OptiPNG can achieve, so depending on the types of assets you have, this can make a difference.
Conclusions:
- JPEG XL and WebP will achieve ~20% reduction for detailed pictures and significantly more for "simpler" pictures over PNG.
- Both JPEG XL and WebP achieve similar results overall, but results will favor one or the other depending on the picture type.
- Both JPEG XL and WebP are much faster and yield better results than using OptiPNG. (I have also seen OptiPNG yield corrupted results in the past, so you need to verify the results.)
- There may be further parameters to yield even better results under specific conditions for these formats.
- AVIF is a disappointment for lossless compression, thanks to it's normal "lossless" setting not being lossless.
- Differences can be quite significant for hosts of websites and distributers of software.
- Lossy compression isn't tested, and may paint a very different picture. (and I don't even know yet how to do a fair comparison).
Further exploration is encouraged.
