Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

118.21. libavif-1.4.2

AVIF reader and writer — the AV1 still-image format, with avifenc and avifdec

Version 1.4.2, release 1
Shelf image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output
Phase 41_system (System), 700 of 1047 in build order
Licence BSD-2-Clause AND MIT
Homepage https://github.com/AOMediaCodec/libavif
Build time 0.3 SBU
Installed size 1.3 MiB in 17 files
Recipe ports/core/image-libs/libavif/kpkgbuild

About

libavif reads and writes AVIF, the still-image format built on the AV1 video codec, with the avifenc and avifdec converters and a gdk-pixbuf loader. Like libheif it codes nothing itself: dav1d decodes and svt-av1 encodes. The web engines, SDL’s image libraries, opencv, gdal, chafa and darktable open AVIF files through it.

Sources

Dependencies

Depends on: cmake, pkgconf, dav1d, svt-av1, libyuv, libwebp, libxml2, libjpeg-turbo, libpng, zlib, gdk-pixbuf, lowdown.

Required by (14): celestia, chafa, darktable, endless-sky, gdal, kimageformats, libgd, opencv, python3-pillow, sdl2-image, sdl3-image, swayimg, webkitgtk, webkitgtk6.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install libavif'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/libavif.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/image-libs/libavif
echo '2b645287340ba5a631d268b551dc2d72bd73ac33335962dd36dcdb6d8366921d  libavif-1.4.2.tar.gz' | sha256sum -c -
echo '7727b0498851e5b6a6fcd734eb667a8a231897e2c86a357aec51cc0664813060  libargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/libavif
SRC=$SRC_ROOT/libavif-1.4.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libavif-1.4.2.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf libargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz -C "$SRC_ROOT"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _argparse and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p build && cd build
cmake .. \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DBUILD_SHARED_LIBS=ON \
	-DFETCHCONTENT_FULLY_DISCONNECTED=ON \
	-DFETCHCONTENT_SOURCE_DIR_LIBARGPARSE="$SRC_ROOT/libargparse-$_argparse" \
	-DAVIF_CODEC_DAV1D=SYSTEM \
	-DAVIF_CODEC_SVT=SYSTEM \
	-DAVIF_CODEC_AOM=OFF \
	-DAVIF_CODEC_LIBGAV1=OFF \
	-DAVIF_CODEC_RAV1E=OFF \
	-DAVIF_CODEC_AVM=OFF \
	-DAVIF_LIBYUV=SYSTEM \
	-DAVIF_LIBSHARPYUV=SYSTEM \
	-DAVIF_LIBXML2=SYSTEM \
	-DAVIF_JPEG=SYSTEM \
	-DAVIF_ZLIBPNG=SYSTEM \
	-DAVIF_GTEST=OFF \
	-DAVIF_FUZZTEST=OFF \
	-DAVIF_BUILD_APPS=ON \
	-DAVIF_BUILD_TESTS=OFF \
	-DAVIF_BUILD_EXAMPLES=OFF \
	-DAVIF_BUILD_GDK_PIXBUF=ON \
	-DAVIF_BUILD_MAN_PAGES=OFF
make
make DESTDIR=$PKG install

install -d "$PKG/usr/share/man/man1"
for page in avifenc avifdec; do
	lowdown -s -Tman \
		-M title=${page^^} -M section=1 -M source="libavif $version" \
		-o "$PKG/usr/share/man/man1/$page.1" ../doc/$page.1.md
done

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libavif, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf libavif-1.4.2-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libavif, and runs the triggers its paths call for.

Contents

Installed programs: avifdec, avifenc, avifgainmaputil.

Installed libraries: libavif.so.

Installed directories: /usr/include/avif, /usr/lib/cmake/libavif, /usr/share/licenses/libavif.

Short descriptions

avifdec decompress an AVIF file to an image file
avifenc compress an image file to an AVIF file
libavif.pc Library for encoding and decoding .avif files

Notes

The pages’ pandoc title block reads AVIFENC(1) | General Commands Manual, which lowdown does not take apart, so build.sh passes the title, the section and the source line as -M metadata.

The helper _argparse names the libargparse commit, and it must be the one libavif pins: AVIF_LIBARGPARSE_GIT_TAG in cmake/Modules/LocalLibargparse.cmake. A new libavif release that moves that tag needs the helper and the second source’s sha256 = line moved with it.