118.12. libwebp-1.6.0
Library and support programs to encode and decode images in WebP format
| Version | 1.6.0, release 1 |
| Shelf | image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output |
| Phase | 41_system (System), 686 of 1047 in build order |
| Licence | BSD-3-Clause |
| Homepage | https://developers.google.com/speed/webp |
| Build time | 0.7 SBU |
| Installed size | 1.8 MiB in 45 files |
| Recipe | ports/core/image-libs/libwebp/kpkgbuild |
About
libwebp is Google’s WebP codec: libwebp, the decoder-only libwebpdecoder, libwebpmux and libwebpdemux for animated and annotated files, and libsharpyuv, its RGB to YUV converter, which libavif and libheif also use. The tools are cwebp, dwebp, gif2webp, img2webp, webpinfo and webpmux. The browsers, the toolkits’ image loaders, imagemagick and ffmpeg link it.
Sources
libwebp-1.6.0.tar.gz(4.1 MiB)
sha256e4ab7009bf0629fd11982d4c2aa83964cf244cffba7347ecd39019a9e38c4564
upstream: https://downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz
archive copy: sources-3/image-libs--libwebp-1.6.0.tar.gz
Dependencies
Depends on: cmake, ninja, libjpeg-turbo, libpng, libtiff, giflib.
Required by (40): blender, chafa, chromium, darktable, ffmpeg, firefox-esr, freerdp, gdal, gegl, gimp, gnuplot, graphicsmagick, graphviz, gst-plugins-bad, gthumb, imagemagick, imv, krita, lagrange, leptonica, libavif, libgd, libheif, libreoffice, librewolf, libvips, netsurf, opencv, openimageio, orcaslicer, python3-pillow, qt6-qtimageformats, qt6-qtwebengine, sdl2-image, sdl3-image, swayimg, thunderbird, webkitgtk, webkitgtk6, webp-pixbuf-loader.
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 libwebp'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/libwebp.
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/libwebp
echo 'e4ab7009bf0629fd11982d4c2aa83964cf244cffba7347ecd39019a9e38c4564 libwebp-1.6.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/libwebp
SRC=$SRC_ROOT/libwebp-1.6.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libwebp-1.6.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:
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DWEBP_ENABLE_SIMD=ON \
-DWEBP_BUILD_LIBWEBPMUX=ON \
-DWEBP_BUILD_EXTRAS=ON \
-DWEBP_BUILD_VWEBP=OFF \
-DWEBP_ENABLE_SWAP_16BIT_CSP=ON
ninja
DESTDIR=$PKG ninja install
test -f "$PKG/usr/share/WebP/cmake/WebPConfig.cmake"
for _l in libwebp.so.7 libwebpdecoder.so.3 libwebpdemux.so.2 libwebpmux.so.3 libsharpyuv.so.0; do
test -e "$PKG/usr/lib/$_l"
done
The switches, and why each is set:
-DWEBP_ENABLE_SIMD=ON— Build the SIMD code paths; upstream’s default for every target but Emscripten, named in the recipe.-DWEBP_BUILD_LIBWEBPMUX=ON— Buildlibwebpmux, which reads and writes the chunks of an extended or animated WebP file. Upstream’s default, named.-DWEBP_BUILD_EXTRAS=ON— Build the extras,get_distoandwebp_quality; upstream installs neither, so the package is the same without them.-DWEBP_BUILD_VWEBP=OFF— Build neither viewer:vwebp, which needs OpenGL and GLUT, nor the SDLvwebp_sdlamong the extras, which is built under the same switch whenever SDL2 is found.-DWEBP_ENABLE_SWAP_16BIT_CSP=ON— Write the two bytes of each pixel in the 16-bit output modes, RGB565 and RGBA4444, swapped: low byte first, which is the pixel’s in-memory order as a little-endian 16-bit value. A program that asks the decoder for one of those modes sees the difference; the 24- and 32-bit modes are unaffected.
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/libwebp, 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 libwebp-1.6.0-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/libwebp, and runs the triggers its paths call for.
Contents
Installed programs: cwebp, dwebp, gif2webp, img2webp, webpinfo, webpmux.
Installed libraries: libsharpyuv.so, libwebp.so, libwebpdecoder.so, libwebpdemux.so, libwebpmux.so.
Installed directories: /usr/include/webp, /usr/share/WebP, /usr/share/licenses/libwebp.
Short descriptions
cwebp |
compress an image file to a WebP file |
dwebp |
decompress a WebP file to an image file |
gif2webp |
Convert a GIF image to WebP |
img2webp |
create animated WebP file from a sequence of input images. |
webpinfo |
print out the chunk level structure of WebP files along with basic integrity checks. |
webpmux |
create animated WebP files from non-animated WebP images, extract frames from animated WebP images, and manage XMP/EXIF metadata and ICC profile. |
libsharpyuv.pc |
Library for sharp RGB to YUV conversion |
libwebp.pc |
Library for the WebP graphics format |
libwebpdecoder.pc |
Library for the WebP graphics format (decode only) |
libwebpdemux.pc |
Library for parsing the WebP graphics format container |
libwebpmux.pc |
Library for manipulating the WebP graphics format container |
Notes
build.sh checks the install before packaging: the CMake package file /usr/share/WebP/cmake/WebPConfig.cmake must exist, and so must each of the five libraries under the soname the loop names. A release that changes one of those sonames stops the build, instead of leaving every program linked against the old name without its library.
cwebp and img2webp read PNG, JPEG and TIFF, dwebp writes PNG, and gif2webp reads GIF. Each of those four libraries is found with a plain find_package, which leaves its format out without an error when the library is missing; all four are in depends so that each is present when the configure runs. Because libwebp depends on libtiff, libtiff is built without WebP support; see libtiff.