Image formats

AVIF: what it is and how to serve it

AVIF is the newest of the common web image formats. It is usually the smallest at the same visual quality, which makes pages lighter, at the cost of slower encoding.

AVIF

  • Files.avif
  • Fileboy reads itNo
  • Fileboy writes itYes

What it is

AVIF is a still-image format built on the AV1 video codec. It supports transparency, wide colour and an animation, and a lossy or lossless mode.

At similar visual quality, AVIF files come out smaller than WebP and much smaller than JPEG. In Fileboy's own tests, photos were about 30% smaller than WebP, and graphics and smooth gradients up to half the size. The price is encoding time: it takes much longer than JPEG or WebP.

Browser support

Current versions of Chrome, Edge, Firefox and Safari all show AVIF. Older browsers and some apps outside the browser, such as email clients and older image editors, may not. That is why it is best served by asking the browser what it accepts, with a fallback.

Serve it with Fileboy

Media typeimage/avif
Read by the image pipelineNo
Written by the image pipelineYes

Fileboy writes AVIF but does not read it. Upload a JPEG, PNG or WebP and ask for AVIF with format:avif, or let format:auto choose: it sends AVIF when the browser's Accept header lists it, WebP when it doesn't, and the original format otherwise.

AVIF is slow to make, so an image over 16 megapixels (4096 by 4096) is sent as WebP instead. The response's Content-Type says which you got. With the lossless transform, auto picks WebP over AVIF. An AVIF file you upload is stored and served as it is, with no resizing.

An image URL
https://api.fileboy.io/images/get/FILE_ID?transform=resize:1200x_;format:auto

Common questions

Can Fileboy resize an AVIF I upload?

No. The image pipeline writes AVIF but can't read it, so an AVIF upload is served untouched. Upload the original JPEG, PNG or WebP and let Fileboy make the AVIF.

Why did I get a WebP when I asked for AVIF?

AVIF takes a lot of work to encode, so an image over 16 megapixels is written as WebP instead. Resize it first, in the same chain, if you need AVIF.

Other formats

Add Fileboy to your next project

We built Fileboy to stop rebuilding file handling for every app. Create an app, paste your key and upload a file. The free plan needs no card.