AVIF is the hip new image format. It is born out of video compression technology. Modern video streaming services have a complicated relationship with multiple resolutions. A video is usually encoded several time – for high, medium, and low bandwidths. When you start streaming, your playback device usually picks the lowest quality stream to start with. If it downloads it quickly, then it jumps to the higher resolution. You may have noticed this when the first few seconds of a streaming show are blocky and horrible, only to snap into a higher resolution.
In the meantime, here’s how to fake a thumbnail for an AVIF picture. You will need a modern browser with AVIF enabled to view these examples.
The trick is that AVIF can be highly effective at low resolutions.
- Take your original JPG image and reduce it in size to, say, 5%.
- Using CAVIF – or your favourite encoder – create the lowest possible quality conversion.
cavif --speed=1 --quality=1 small.jpg
- Base64 encode the resultant image.
- Set it as the background-image in your CSS:
Here’s what it looks like while the main image is loading (you may need to enable AVIF in your browser:
Obviously, it isn’t pretty! But it will allow something to be displayed while your full resolution image is slowly loading.