I tried comparing encodings myself too, though in my case I tried lossless compressions, in case you decide to to reduce the size of the offline files without loosing the quality:
Edit: Forgot to mention, I used the 0.1.1 version in this test, in case you want to reproduce.
| | Total | % Total | 503 Images | % Images | Time | | ——— | —— | —–– | ––––– | –––– | –––– | | Original | 437 MB | 100 % | 168 MB | 100 % | 00:00:00 | | Optimized | 418 MB | 96 % | 150 MB | 89 % | 01:00:00 | | Webp | 364 MB | 83 % | 94 MB | 56 % | 00:04:04 | | JPEG XL | 345 MB | 79 % | 77 MB | 46 % | 04:21:02 | | AVIF | 396 MB | 91 % | 127 MB | 76 % | 00:36:49 |
Edit: Damn, looks like the markdown engine doesn’t support tables, using an image instead:
Notes:
- The measured time are not very accurate, since I was using the system at the same time as the encoding was happening. I also lost the time it took to optimize PNGs, so I just put how long I thought it took (about an hour). Still, it should give a rough indication on encoding speed.
- I used the most aggressive settings on all encodings, in other words, I let the tools use as much time as needed to get as little files as possible. A more sane configuration would probably reduce the time while keeping most of the space saving.
cjxl
(the tool used to encode to jxl) didn’t seem to use more than one core even though I told it to use 32 threads, next time I’d parallelize jobs manually, e.g. usingForEach-Object -Parallel
.
Commands used:
- For optimization I used PNGGauntlet, which is a GUI application that “Combines PNGOUT, OptiPNG, and DeflOpt to create the smallest PNGs”
cwebp -preset drawing -lossless -z 9 -m 6 -pass 5 -quiet IMAGE.png -o IMAGE.webp
cjxl IMAGE.png IMAGE.jxl -a 0 -q 100 -e 10 –num_threads=32 --quiet
avifenc --lossless -q 100 –qalpha 100 -s 0 --jobs 32 IMAGE.png IMAGE.avif
Takeaway: Even though AVIF generally has the best compression ratio when using lossy compression, it’s only a bit better than an optimized PNG when using lossless compression (and it’s not actually 100% mathematically lossless, since AVIF doesn’t support the same color space that PNG uses, so there’s some change during color space conversion). The best format seems to be JPEG XL, unfortunately Google really wants to push WEBP and AVIF, which are both fully or partially designed by Google, so support for JXL is not good, so with that said, the best all around for lossless compression seems to be WEBP with almost half the space of PNG while still being 100% lossless, but also the fastest to complete the encoding due to the maturity of the libraries.