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
libheif-1.23.6.tar.gz(2.3 MiB)
sha2564484346dc5995319dbc11e3a1c35d0a2ec46511ce370900869337fd2c7033125
upstream: https://github.com/strukturag/libheif/releases/download/v1.23.6/libheif-1.23.6.tar.gz
archive copy: sources-3/image-libs--libheif-1.23.6.tar.gz
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.
-DWITH_X264=OFF, line 27: x264 (explained with the switches below)
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 |
-DWITH_LIBDE265=ON— WithWITH_X265,WITH_DAV1D,WITH_SvtEnc,WITH_OpenH264_DECODER,WITH_JPEG_DECODER,WITH_JPEG_ENCODER,WITH_OpenJPEG_DECODERandWITH_OpenJPEG_ENCODER, build the codecs in the table. Each is afind_packagethat, when its library is missing, printsnot foundand builds without the codec, so every one of them is independs. dav1d, svt-av1 and the two OpenJPEG codecs are built as plugins in/usr/lib/libheif, upstream’s default for them; the rest are linked into the library.-DWITH_AOM_DECODER=OFF— With-DWITH_AOM_ENCODER=OFF, build no codec on libaom, a second AV1 decoder and encoder; libaom is not a port.-DWITH_X264=OFF— Build no H.264 encoder. x264 is a port, so this is a choice the recipe makes: libheif here decodes AVC-coded images through OpenH264 and cannot write them.-DWITH_RAV1E=OFF— WithWITH_KVAZAAR,WITH_UVG266,WITH_VVDEC,WITH_VVENCandWITH_OPENJPH_ENCODERoff, build none of the codecs on rav1e, kvazaar, uvg266, vvdec, vvenc and OpenJPH; none of those libraries is a port.-DWITH_FFMPEG_DECODER=OFF— Build no decoder on ffmpeg’s libavcodec. It would be a second HEVC decoder beside libde265, and ffmpeg is built in a later phase,42_graphics.-DWITH_WEBCODECS=OFF— Build no HEVC decoder on a web browser’s WebCodecs API, an experimental path upstream leaves off by default.-DWITH_UNCOMPRESSED_CODEC=ON— Support the ISO/IEC 23001-17 uncompressed codec, which libheif implements itself; its deflate and brotli variants use zlib and brotli. Upstream marks it experimental and builds it only when asked.-DWITH_HEADER_COMPRESSION=ON— Support compressed metadata boxes, through zlib.-DWITH_LIBSHARPYUV=ON— Convert between RGB and YCbCr with libwebp’slibsharpyuv, upstream’s higher-quality conversion, from the libwebp port.-DWITH_EXAMPLES=ON— Build theheif-*command-line programs.-DWITH_EXAMPLE_HEIF_THUMB=ON— Buildheif-thumbnailer, the thumbnailer file managers call.-DWITH_EXAMPLE_HEIF_VIEW=OFF— Build noheif-view, an SDL2 viewer that is otherwise built whenever SDL2 happens to be installed.-DWITH_GDK_PIXBUF=ON— Build the gdk-pixbuf loader.-DBUILD_DOCUMENTATION=OFF— Build no Doxygen API reference.
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. |