How to use the next-gen open-sourced .Avif image format, 50% smaller than JPEG
reachlightspeed.com
reachlightspeed.com
It’s 2020 and its mind-boggling that this isn’t a standard behavior already.
Imagine right-clicking on a thumbnail and being able to natively save a 4MB file from it.
Imagine having a single <img> that can be zoomed in all the way to 100% just like your phone’s Photos app can do, without loading the whole image beforehand.
This is basically a solved problem when people use mime types properly for formats. For sizes we'd need a similar way to mime types to ask for a size, html solves this for images with srcset but I'd rather it be within the transport mechanism rather than in the markup.
Requesting an image should be requesting a image, not a specific representation of that image. The representation should be part of the content negotiation that is already a part of the protocol.
> Requesting an image should be requesting a image, not a specific representation of that image.
This is exactly what I’m saying. The image is one, it’s the browser that decides how much of it to load.
It’s the current picture/srcset-based situation that is “a specific representation of that image”
> For sizes we'd need a similar way to mime types to ask for a size
Now that is complicating things. Suddenly the server has to produce/return different resources based on a header. The solution I described could be delivered by any dumb HTTP2 server, without preprocessing.
Technically what I’m describing is already possible with any progressive format like JPEG; The only missing part is that the browser should pause/resume the loading as it sees fit.
All I want for Christmas is:
<img src="you.jpg" progressive>
The obvious advantage is that if the window size changes, the browser only has to fetch the missing data, not a whole new file.The issue with doing this is not with the basic idea, obviously it would be desirable if we could do it, but with the fact that it's actually much less efficient to encode the entire file this way if you want real progressive loading (i.e. stop at any point). It's much more reasonable at present to just dynamically load a reasonably sized image for the current viewport, even before you get to issues like format support.
https://reachlightspeed.com/img/blog/post-using-avif-images-...
https://reachlightspeed.com/img/blog/post-using-avif-images-...
The JPEG file is 112kb and the .avif file is now 55kb.
See the ImageCon slides and the summary from the top comment in [0], or watch the video there.
JPEG XL’s strengths: better image quality, responsive decoding, totally royalty-free (unlike HEIF container in AVIF [1]), legacy-friendly (easy conversion from JPEG, PNG, GIF).
JPEG XL standardization should be complete by the end of 2021 [1].
[0] https://news.ycombinator.com/item?id=21612708
[1] https://cloudinary.com/blog/how_jpeg_xl_compares_to_other_im...
For anyone looking for some image comparisons between AV1 and JPEGXL, someone updated the classic "image format comparison" on Github and added it. [1] Important to note that all these are a little unfair to JPEGXL, because it's explicitly targeting higher bitrates than most of the quality levels you see here, and it still comes out looking pretty good at the higher bitrates.
[1] https://afontenot.github.io/image-formats-comparison/#abando...
Note that achieving high quality results at low bitrates is not really a goal of JPEGXL, or the codecs it's based on. For example the PIK readme contains the following note:
> It prioritizes authenticity, a faithful representation of the original, over aesthetics achievable by by hallucinating details or 'enhancing' (e.g. sharpening/saturating) the input.
So as I noted in the OP, it's not a very fair comparison with bitrates this low, but I think JPEGXL holds its own.
[1] https://afontenot.github.io/image-formats-comparison/#eaglef...
Those other formats weren't developed by huge corporations who can force it into browsers through pure hegemony. That's probably a factor.
The missed opportunity is that AV1 is arriving everywhere and with tiny bit of foresight they could have made that include a new image standard which everyone would then have as well with essentially no additional support needed. Instead we now have to convince all browser vendors and more to support yet another image format that has no widespread adoption.
Is there a poly fill js/warm decoder for older browsers?
There is a polyfill for old browsers but our recommendation would be to use the graceful degradation of the <picture> tag which falls back to <img> if .avif or .webp is not supported.
Further reading: https://www.cnet.com/news/google-mozilla-av1-photo-format-co...
Only supported by Chrome ATM.