libavif

Following https://web.dev/compress-images-avif/

Build (Debian GNU/Linux 11 (bullseye))

# backports must be enabled in /etc/apt/sources.list
sudo apt install -t bullseye-backports libyuv-dev libyuv0

# get the repo
git clone -b v0.11.1 https://github.com/AOMediaCodec/libavif.git

see https://github.com/AOMediaCodec/libavif/releases

cd libavif/ext
./aom.cmd
# sudo apt install ninja # if needed
cd ..
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DAVIF_CODEC_AOM=1 -DAVIF_LOCAL_AOM=1 -DAVIF_BUILD_APPS=1 ..
make

Two new files should appear: avifenc and avifdec, cp both to ~/bin (or some other $PATH)

Use

Proposed for lossy

avifenc --min 0 --max 63 -a end-usage=q -a cq-level=18 -a tune=ssim jenga.png jenga.avif

and you get this 87k file:

or this 50k file:

edit: It might be reasonable to up-depth to 10 bit to make gradients better (-d 10 switch), even if input is 8 bit. 8bit RGB to 10bit YUV is supposedly lossless.

Notes

It’s fast.

Film synthesis?

film-grain-test=TEST
film-grain-table=FILENAME

Test

avifenc --min 0 --max 63 -a end-usage=q -a cq-level=18 -a film-grain-test=16 -a tune=ssim jenga.png jenga3.avif

seems to add some artificial grain to image, but keeps the filesize the same. Unsure if this the same as grain synthesis in libaom.

p.s. The number is grain size (not strenght), where 1 is the smallest and 16 is the biggest. Example with film-grain-test=1:

p.s.2. It is also possible to use denoise-noise-level thing (grain synthesis).

picture

Using slightly noisy crop of the 7d photo and high compression here (38k!) to illustrate the effect:

avifenc --min 0 --max 63 -a end-usage=q -j 8 -a cq-level=35 -a denoise-noise-level=5 -a tune=ssim fotodetail.png fotodetail.avif

Can I use for web

https://caniuse.com/?search=avif


libjxl

(jpeg-xl reference encoder) - Possible future alternative?

https://tonisagrista.com/blog/2023/jpegxl-vs-avif/

Build

follow: https://github.com/libjxl/libjxl/blob/main/BUILDING.md

perhaps needed after install:

sudo ldconfig

Can I use for web (not at the moment)

https://caniuse.com/?search=jpeg-xl

For the low bitrates and set of this 3 images, avif wins ime (in my eyes).

HN debate: https://news.ycombinator.com/item?id=36283395