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

118.3. libjpeg-turbo-3.2.0

A fork of the original IJG libjpeg which uses SIMD to accelerate baseline JPEG compression and decompression

Version 3.2.0, release 2
Shelf image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output
Phase 41_system (System), 92 of 1047 in build order
Licence IJG AND BSD-3-Clause AND Zlib
Homepage https://libjpeg-turbo.org/
Build time 4.3 SBU
Installed size 5.1 MiB in 42 files
Recipe ports/core/image-libs/libjpeg-turbo/kpkgbuild

About

libjpeg-turbo is the JPEG codec: libjpeg, the IJG API that nearly every program reading or writing a JPEG links, accelerated with SIMD kernels, and libturbojpeg, its own simpler API. It also installs cjpeg, djpeg, jpegtran, rdjpgcom, wrjpgcom and tjbench. It is one of the most depended-on libraries in the tree: libtiff, libwebp, libjxl, libheif, libavif, gdk-pixbuf, the toolkits and the browsers all link it.

Sources

Dependencies

Depends on: cmake, ninja, nasm, zlib, libspng.

Required by (111): abiword, ardour, blender, calibre, celestia, chafa, chromium, darktable, digikam, djvulibre, endless-sky, farbfeld, firefox-esr, fltk, fontforge, freerdp, gdal, gdk-pixbuf, gegl, ghostscript, gimp, glmark2, gmsh, gnuastro, gphoto2, graphicsmagick, graphviz, gst-plugins-base, gst-plugins-good, gthumb, gtk4, gutenprint, gwenview, handbrake, hplip, imagemagick, imv, inkscape, ioquake3, jasper, kdos-plasma-look, kodi, krita, lcms2, leptonica, libavif, libcupsfilters, libgd, libgeotiff, libgphoto2, libheif, libjxl, libraw, libreoffice, librewolf, libsixel, libtiff, libvips, libvncserver, libwebp, libyuv, luanti, minidlna, motif, mpv, mupdf, netpbm, netsurf, neverball, opencv, openimageio, openjdk, orcaslicer, pdf4qt, pdfium, podofo, poppler, prusaslicer, python3-pillow, qemu, qmapshack, qpdf, qt5-qtbase, qt6-qtbase, qt6-qtwebengine, qv4l2, R, rawtherapee, remmina, sane-airscan, sane-backends, scummvm, sdl2-image, sdl3-image, spice, spice-gtk, supertuxkart, swayimg, testdisk, thunderbird, timg, v4l-utils, vlc, vtk, warzone2100, webkitgtk, webkitgtk6, wlvncc, wxwidgets, xonotic, zbar.

Patches

build.sh applies these; kpkg applies nothing by itself.

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 libjpeg-turbo'

What kpkg does

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

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/libjpeg-turbo
echo '6f30092cef9fb839779646608f4ee14ae3cbac989c47fa05e841b0841f09878e  libjpeg-turbo-3.2.0.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/libjpeg-turbo
SRC=$SRC_ROOT/libjpeg-turbo-3.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libjpeg-turbo-3.2.0.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:

patch -p1 -i "$PORT_SRC/config-spng-dependency.patch"

cmake -S . -B build -G Ninja \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=/usr/lib \
        -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
        -DWITH_SYSTEM_SPNG=ON \
        -DWITH_SYSTEM_ZLIB=ON \
        -DWITH_TESTS=OFF \
        -DWITH_JPEG8=ON \
        -DWITH_SIMD=ON \
        -DREQUIRE_SIMD=ON \
        -DCMAKE_SKIP_INSTALL_RPATH=ON \
        -Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build

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/libjpeg-turbo, 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 libjpeg-turbo-3.2.0-2.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/libjpeg-turbo, and runs the triggers its paths call for.

Contents

Installed programs: cjpeg, djpeg, jpegtran, rdjpgcom, tjbench, wrjpgcom.

Installed libraries: libjpeg.a, libjpeg.so, libturbojpeg.a, libturbojpeg.so.

Installed directories: /usr/lib/cmake/libjpeg-turbo, /usr/share/doc/libjpeg-turbo, /usr/share/licenses/libjpeg-turbo.

Short descriptions

cjpeg compress an image file to a JPEG file
djpeg decompress a JPEG file to an image file
jpegtran lossless transformation of JPEG files
rdjpgcom display text comments from a JPEG file
wrjpgcom insert text comments into a JPEG file
libjpeg.pc A SIMD-accelerated JPEG codec that provides the libjpeg API
libturbojpeg.pc A SIMD-accelerated JPEG codec that provides the TurboJPEG API

Notes

The recipe leaves ENABLE_STATIC at its default, so libjpeg.a and libturbojpeg.a are installed beside the shared libraries, with the CMake package files under /usr/lib/cmake/libjpeg-turbo. libtiff finds the library through that CMake package, and falls back to the FindJPEG module in its own cmake/ directory only when the package is missing.