The Case for AVIF
Thu 13 February 2025
Disclaimer: Right off the bat, I am NOT an imaging expert, a compression expert, or really an anything expert. I'm just speaking from my own experiences as a relatively ordinary user of image formats.
When I was a young-un in the early, early 90s, PICT was the day-to-day image format I used. For those not familiar with Classic Macintosh formats, it was the Classic Macintosh equivalent of Windows Metafile — the bog standard, the native format of the OS's graphics routines. MacPaint was another option, which provided a decent little bit of very fast (Run-Length Encoding) compression, but was limited to a fixed size: 576 x 720 at 72 dpi (approximately a US letter page, within the margins: 8" x 10" exactly).
For images shared on the Interne— I mean, on BBSes and services like GEnie, there was the glorious GIF standard: arbitrary resolution, up to 256 colors, and 1-bit alpha channel transparency. These took some time to load on my beloved Macintosh SE, but they saved a lot of space.
Then a little later on in the early 90s, I started hearing about this utterly magical compression format called JPEG: It made image sizes much smaller by throwing out unneeded data. Witchcraft!!! I rushed and found a JPEG program for the Mac from an online service and loaded a small JPEG file. It took minutes to decompress, and I found that it didn't really save any space compared to GIF with the images I had (they actually got bigger than the GIFs). I later learned that JPEG wasn't meant for monochrome images! It was like trying to run quartz crystals through a hamburger grinder. It just wasn't going to end well.
Nowadays, while JPEG still gets plenty of use online, there are a lot of other contenders, and many modern smartphones don't even save to JPEG by default! While I won't argue the suitability of JPEG for high-fidelity images (it still has many eloquent apologists who make valid points), I think there are better formats for low-fidelity images, such as for social media sharing.
On the Fediverse (which is the only social media I belong to nowadays), most images are saved and shared as JPEG, while some fediverse servers seem to support WebP.
While WebP (which is backed by Google) provides a lot of savings over JPEG for very small (data-wise) images, I think there are better formats still, and it would be great if the fediverse looked into supporting them.
Methodology
For these examples, I took a very high quality, high resolution PNG of a thinkpad (with some transparency), and reduced it to 640 x 506 resolution. I then took that lower resolution (but very high quality) PNG and saved it as a JPEG with 10% quantization using GIMP. I then tried to produce images of the same (file) size using the other formats for comparison.
PNG
First, let's look at the source (640 x 506) PNG:
171,605 byte PNG
JPEG
Now, here's the JPEG I created in GIMP using 10% quantization/quality:
9,745 byte JPEG at 10% quantization, converted with GIMP
JPEG gives you the basic idea, but there's a great deal of loss, as each 8x8 pixel block has very little detail. It looks like a mosaic. Again, not hating on the format — it was amazing for 1992, and is still great for high-fidelity images. But it wasn't meant to do miracles.
WebP
Now, let's see what WebP (derived from the VP8 open video format) can do at about the same file size:
9,546 byte WebP at 44% quantization, converted by GIMP
We're getting a LOT better, now. The mosaic look is gone. Things are quite blurry in places, but the gradients are smooth. The detail is lacking, but the overall picture is quite nice. The transparency is intact, as well.
AVIF
Another new free format that hasn't been getting nearly as much love is AVIF. It's based on the AV1 open video codec, and I think it has a lot of promise.
Here's the same image, compressed down to a 9,413 byte AVIF with 46% quantization via GIMP:
9,413 byte AVIF at 46% quantization converted by GIMP
For basically the same file size, AVIF does a little better job at representing details comapred to WebP. The edge of the image where the transparency is happening is also much smoother, but that may be a fluke of how I exported it from GIMP, not sure.
I found it easiest to view each image in their own tab, zoomed in 200% or 300% and then flip back and forth quickly to notice the differences.
I will also provide other formats I was able to try with minimal commentary:
HEIC
HEIC is the common extension for HEVC (h.265)-encoded image data stored within a HEIF file. While HEIF is an open standard, HEVC is patent-encumbered, which reduces its suitability for broad use. In spite of this, all iPhones since 2017 save images as .HEIC (HEVC image encoded in HEIF) by default, which has been known to cause issues.
9,433 byte HEIC at 31% quantization, converted by GIMP
JPEG-XL
JPEG-XL is another open format which unfortunately has not recieved a lot of support from modern web browsers.
9,361 byte JPEG-XL at 18% quantization, converted by libjxl-tools
JPEG 2000
JPEG 2000 is an upgrade to the original JPEG that was designed in the latter 90s. It provides better performance than JPEG, but doesn't compare well to the newer compressors.
8,955 byte JPEG 2000 at 31% quantization, converted by ImageMagick
Conclusion
Of all the formats, AVIF seems to offer the best performance in a default browser, with HEIC, JPEG-XL, and JPEG 2000 not even displaying in Firefox 128esr. I'm glad that some Fediverse servers already support WebP, which is a great step forward beyond JPEG for image reproduction at ultra-low file sizes, but I think AVIF might be a better fit. Either way, I think all fediverse software projects should look into using somethign like WebP or AVIF internally be default in order to save storage and bandwidth.
P.S., It's pronounced JIF.
100 Days to Offload 2025 - Day 12
Category: Tech Tagged: 100DaysToOffload Computing Federated Services FOSS (Free and Open Source Software) Linux Non-religious post Philosophy Productivity Retrocomputing Social Media