104 points · by speckx · 3w ago · 83 comments
I added AVIF support to my personal image resizing tool recently - https://tools.simonwillison.net/image-resize-quality - I mostly use that for screenshots though, and WebP works better for those.
I have a similar tool at https://pictolab.io. I use it for tweaking the brightness and satuation of images mostly. For that you want HDR to reduce clipping, and most image formats have surprisingly bad HDR support besides AVIF (and jxl). Jpeg kinda supports it with gain maps but it's kind of tacked-on to the spec. Webp doesn't support HDR at all.
It's also surprisingly hard to support HDR input. For example, Apple uses a weird poorly documented format for the HEIC their iPhones take. I feel like HDR is just kind of a mess right now.
Interesting! Better in terms of more quality preserved or smaller file size? Have you found other types of images where this applies?
Odd argument.
Image isn’t video and we are not YouTube.
So please don't ruin my battery life just to save a few percent on your egress traffic bill.
From my experience throwing random JPEGs at it, it's 3 to 4 times smaller, that's a good chunk of data saved, which in turn is a lot of energy saved on visitors' radios being active.
Unlike with jpeg, you don't need 85 or 95 percent on the quality score, 50 is more than good enough for most pictures on a website.
If you're hosting images and want a fully lossless encoding the CPU time may become a factor, but if you're hosting user generated content, I don't think it's all that bad. Plus, you can just move the encoding part to the user side of the equation and pretend it's part of the upload progress bar if you're desperate to pay the power bill.
Still, when encoding AVIF, there are various quality options to choose from, and the encoder has gotten better over the past year. On my i3-2120 NAS (which even your E5 should beat on single core perf), encoding an image at default speed takes about 4-6 seconds (JPEG about 2s), while producing an image of comparable quality a third the size. If I pass --speed 10, converting PNG to AVIF takes only half a second.
The standard AV1 encoder has improved a lot over a short amount of time, I invite you to run another benchmark, you may be surprised.
If you want to optimize the user-facing side, you might want to pick HEIC instead to optimize for commonly available HEVC/h.265 hardware encoding capabilities, or to be selective instead and pick AVIF when AV1 capabilities are present.
AVIF is notoriously CPU-intensive to compress without acceleration, but assuming you pay for storage and/or delivery, the results are impressive. JPEG-XL and HEIC also do very well. JPEG really shouldn't be used unless you're trying to target devices that can only read JPEG.
So don't do that, please.
For various reasons, AVIF and HEIF/HEIC support is generally bundled together in the same decoders. Both of CrabbyAVIF and libheif, for example, read both AVIF and HEIF/HEIC, so while HEIC might sometimes be supported without AVIF, it's harder to have support for AVIF with HEIF/HEIC.
Browsers are a bit weird, not sure why they haven't enabled support.
(It would be an entirely new thing for you to use hardware decoders for stills, so no reason to worry about it as something restrictive.)
Regarding HEIC, you know the browser acceptance for this, do you? https://caniuse.com/?search=heic
120 seconds is an arbitrary number to throw out there, AVIF compression time is purely dependent on how aggressive you want the file compressed. The ability to go completely nuts with computation is great for when you create the assets once for example.
Native browser support for HEIC is poor, yes. No idea why tbh, the underlying libraries generally support it. Heck, AVIF and HEIF/HEIC support is almost universally bundled together.
Take CrabbyAVIF and libheif: both provide both AVIF and HEIF/HEIC support. Android uses CrabbyAVIF as the platform AVIF/HEIF reader for reference, and considering that Google Photos natively supports HEIF/HEIC (even in browser). They're also using CrabbyAVIF in Chromium, but for some reason they disabled the HEIF/HEIC feature.
If you're making browser apps, you will ultimately care about storage and bandwidth, so AVIF or JPEG-XL are your main options. Outside browser apps you can pick entirely as you please, and if end-user encoder performance matters, HEIC ends up likely winning as hardware AV1 encoders are still less common.
I don't know if anyone has published an encode time / quality comparison of the various encoders. It'd have to be recent to include this year's libaom image optimizations.
https://symbiogenesis.github.io/DotJpegli/
However, video would matter so much more than images, to the overall internet, that images don't even matter by comparison.
(I’m not saying I support the claims or not, I have no idea about their technical and let alone legal merit, just thinking that there are attempts at enforcement against sites streaming AV1 and whether choosing AV1 puts say my site at risk)
I know I had to pay like $1.99 on my synology for H265 support, and likewise for “Advanced Media Extensions” on windows 10/11, although that may have changed.
No need to worry about these risks for using it though. You can never say that no patent troll will surface tomorrow for literally anything. That's not a reason not to use things.
Well I guess you can use 20+ year old standards when they exist.
So far I haven't performed a benchmark where AVIF has a decisive advantage in any real scenario; none of the scenarios I tested accept the quality loss or compute necessary.
For the rest of us, this resource debunks all stupid jxl propaganda.
Who cares if AVIF is slightly smaller at some specific scenario when Mercury is in retrograde, when it takes a century to encode?
My entire point is that some 3% size gain is acceptable for shortening the encode time by 97%, which is what JPEG XL does.
JPEG XL vs. AVIF for web use-cases
The comparison is more about who has had the most man-hours and megadollars put into encoders quality than about the inherent limitations about the format.
With that said, I use AVIF, but I do have what can be said to be an irrational preference for JXL.
Is it irrational to follow the collective "one format to rule them all" dream? Sure, the codec itself needs work, but seeing how long we've been stuck with the JPEG/PNG/GIF trio (even with better encoders like mozjpeg/jpegli or optipng/zopfli) with TIFF as a catch-all backup, getting the format right once and for all really matters.
I'm still weirded by the low amount of workforce in libjxl/jxl-rs; sure, too many cooks do ruin the broth, but too few too, in that domain.
In terms of picture quality for given size, AVIF has it solidly beat.
For arbitrary planes, AVIF calls them auxiliary images. Unless you mean encoding non-RGB data to start with like how DNG uses JPEG-XL. At which point you're outside the scope of any standard interpretation of JPEG-XL data.
Huh?
JpegXL is the only widely supported format (once it comes to the various browser as is planned) that can store true HDR linear images in floating point (fp16 and fp32) formats.
AVIF can only do 10 bit integer ranges, sure that HDR compared to 8bit but it is not sufficient for useful extended range color spaces.
Also AVIF supports up to 12 bits.
Just about anything is better than jpeg these days.
Just like you can assume most PNGs to be lossless (despite supporting pallettes, which pngquant uses to "compress" them) and non-animated (despite APNG being over 22 years old), you can assume most AVIF and WebP images are lossy. Same with JXL. HEIF requires a bit of special care (it's only produced by devices with HDR support so your pipeline needs to fit that) but that's pretty much it.
You may get surprised by an accidental, huge lossless AVIF/WebP/HEIF file, but most sources where you can even get these files are all lossy. Unless you recompress your photo library yourself, of course, but then you have full control over the entire process and can decide whether or not you want lossy or lossless.
Where AVIF isn’t supported, I reckon you’re better to fall back to JPEG. Everything supports JPEG, but there are still plenty of things that don’t support WebP. Anything that supports WebP now has indicated it’s open to supporting newer formats than the baseline JPEG/GIF/PNG and is almost certain to support AVIF within a few years.
Are you looking for jpeg XL?
> and do not leverage any existing infrastructure for serving video
How would that leveraging work?
> WebP, AVIF are the webscale equivalent of serving images.
This sounds insulting? But they are images on the Web. I have no idea what you mean here.
By contrast, if you let the user upload a JPEG or even a PNG, you might pay a slightly-higher cost of the incoming bandwidth, but then you (basically for free) transform the image to the small dimensions and format you actually need, and from there the bandwidth is barely a problem.
Sidenote: End users hate WEBP because nearly any software other than web browsers still don't support even reading it, let alone outputting it (and as you pointed out, anywhere that you "upload an image" they're not welcome either).
In my incredibly shoddy testing sample of 1, my current-macOS device does open AVIFs in Preview, so that's an improvement, at least!
It's still a very small number of programs that support it on the desktop, but at least Preview is working now. So I stand corrected.
I’ll just drop my AVIF local support for Wordpress plugin here: https://github.com/ddegner/avif-local-support
Ouch. Pretty much every browser supports AVIF now which means everyone gets transcoded images worse than JPEGs one uploaded. For JPEG XL that process is lossless...
Recompressing is not great, but many people might be happy with a file that is less than half the size even if they lost a bit of fidelity. Not everyone has original source material to work with after all.
Because whenever I download an image and its webp, the next thing i do is i google "webp to png/jpg" conversation because yeah service XY or Tool Z doesn't support it.
Or my Fire TV Stick :(
I configure my nginx to serve everything available though. Thats what i can do.
It's been a while since Photoshop finally got support, though, I can't recall the last time webp posed a problem for me. Then again I don't use a Firestick, no idea how that would deal with image formats, I guess it's no longer being maintained?
H265 for example. Or Dolby Vision.