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

118.18. libheif-1.23.6

HEIF and AVIF image reader and writer

Version 1.23.6, release 1
Shelf image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output
Phase 41_system (System), 697 of 1047 in build order
Licence LGPL-3.0-or-later AND MIT
Homepage https://github.com/strukturag/libheif
Build time 2.0 SBU
Installed size 4.7 MiB in 51 files
Recipe ports/core/image-libs/libheif/kpkgbuild

About

libheif reads and writes HEIF, the container a phone camera writes its photos in (HEIC) and the one AVIF uses, with heif-dec, heif-enc, heif-info, heif-thumbnailer and a gdk-pixbuf loader. It does no coding itself: each compression format is a codec library behind a plugin interface. gimp, darktable, digikam, krita, imagemagick, graphicsmagick, libvips, chafa and the KDE image-format plugins open HEIC files through it.

Sources

Dependencies

Depends on: cmake, libde265, x265, dav1d, svt-av1, libjpeg-turbo, libpng, libtiff, libwebp, gdk-pixbuf, openjpeg, zlib, brotli, openh264.

Required by (16): chafa, darktable, digikam, gdal, gimp, graphicsmagick, gthumb, imagemagick, imv, kimageformats, krita, libgd, libvips, openimageio, python3-pillow-heif, swayimg.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

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 libheif'

What kpkg does

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

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/libheif
echo '4484346dc5995319dbc11e3a1c35d0a2ec46511ce370900869337fd2c7033125  libheif-1.23.6.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/libheif
SRC=$SRC_ROOT/libheif-1.23.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libheif-1.23.6.tar.gz -C "$SRC" --strip-components=1

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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p build && cd build
cmake .. \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DBUILD_SHARED_LIBS=ON \
	-DBUILD_TESTING=OFF \
	-DWITH_EXAMPLES=ON \
	-DWITH_LIBDE265=ON \
	-DWITH_X265=ON \
	-DWITH_DAV1D=ON \
	-DWITH_SvtEnc=ON \
	-DWITH_AOM_DECODER=OFF \
	-DWITH_AOM_ENCODER=OFF \
	-DWITH_X264=OFF \
	-DWITH_OpenH264_DECODER=ON \
	-DWITH_JPEG_DECODER=ON \
	-DWITH_JPEG_ENCODER=ON \
	-DWITH_OpenJPEG_DECODER=ON \
	-DWITH_OpenJPEG_ENCODER=ON \
	-DWITH_RAV1E=OFF \
	-DWITH_KVAZAAR=OFF \
	-DWITH_UVG266=OFF \
	-DWITH_VVDEC=OFF \
	-DWITH_VVENC=OFF \
	-DWITH_OPENJPH_ENCODER=OFF \
	-DWITH_FFMPEG_DECODER=OFF \
	-DWITH_WEBCODECS=OFF \
	-DWITH_UNCOMPRESSED_CODEC=ON \
	-DWITH_HEADER_COMPRESSION=ON \
	-DWITH_LIBSHARPYUV=ON \
	-DWITH_GDK_PIXBUF=ON \
	-DWITH_EXAMPLE_HEIF_THUMB=ON \
	-DWITH_EXAMPLE_HEIF_VIEW=OFF \
	-DBUILD_DOCUMENTATION=OFF
make
make DESTDIR=$PKG install

The switches, and why each is set:

Every codec is named, on or off, so the codec set is written in the recipe rather than inherited from upstream’s defaults. One decoder and one encoder are built per format:

Format Decoder Encoder
HEIC (H.265) libde265 x265
AVIF (AV1) dav1d svt-av1
AVC (H.264) openh264 none
JPEG in HEIF libjpeg-turbo libjpeg-turbo
JPEG 2000 in HEIF openjpeg openjpeg

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/libheif, 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 libheif-1.23.6-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/libheif, and runs the triggers its paths call for.

Contents

Installed programs: heif-convert, heif-dec, heif-enc, heif-info, heif-thumbnailer.

Installed libraries: libheif.so.

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

Short descriptions

heif-dec decode HEIC/HEIF image
heif-enc convert image to HEIC/HEIF
heif-info show information on HEIC/HEIF file
heif-thumbnailer create thumbnails from HEIC/HEIF files
libheif.pc HEIF image codec.