118.7. openjpeg-2.5.4
JPEG 2000 codec — what scanners, archives and PDFs put images in
| Version | 2.5.4, release 1 |
| Shelf | image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output |
| Phase | 41_system (System), 101 of 1047 in build order |
| Licence | BSD-2-Clause |
| Homepage | https://www.openjpeg.org/ |
| Build time | 0.8 SBU |
| Installed size | 1.1 MiB in 18 files |
| Recipe | ports/core/image-libs/openjpeg/kpkgbuild |
About
OpenJPEG is the JPEG 2000 codec, libopenjp2, with the opj_compress, opj_decompress and opj_dump tools. poppler and mupdf decode the JPEG 2000 images inside PDFs through it, and imagemagick, gimp, ghostscript, leptonica, libheif and the web engines link it.
Why it is in KDOS
The comment above openjpeg and openexr in script/phases/41_system/packages.d/image-libs.txt:
ffmpeg and imagemagick are configured against these and are only as capable as what is installed: each build system answers a missing library by disabling the feature rather than failing.
Sources
openjpeg-2.5.4.tar.gz(2.1 MiB)
sha256a695fbe19c0165f295a8531b1e4e855cd94d0875d2f88ec4b61080677e27188a
upstream: https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.5.4.tar.gz
archive copy: sources-3/image-libs--openjpeg-2.5.4.tar.gz
Dependencies
Depends on: cmake, zlib, libpng, libtiff, lcms2.
Required by (26): blender, darktable, dcmtk, gdal, ghostscript, gimp, gst-plugins-bad, imagemagick, kimageformats, krita, leptonica, libheif, libreoffice, libvips, mupdf, opencv, openimageio, pdf4qt, pdfium, poppler, python3-pillow, qsstv, qt6-qtwebengine, 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 openjpeg'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/openjpeg.
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/openjpeg
echo 'a695fbe19c0165f295a8531b1e4e855cd94d0875d2f88ec4b61080677e27188a openjpeg-2.5.4.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/openjpeg
SRC=$SRC_ROOT/openjpeg-2.5.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf openjpeg-2.5.4.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_STATIC_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_CODEC=ON \
-DBUILD_THIRDPARTY=OFF \
-DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_PNG=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_TIFF=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_LCMS2=ON
make
make DESTDIR=$PKG install
install -Dm644 ../doc/man/man1/*.1 -t $PKG/usr/share/man/man1
install -Dm644 ../doc/man/man3/*.3 -t $PKG/usr/share/man/man3
The switches, and why each is set:
-DBUILD_CODEC=ON— Build theopj_*command-line tools. This is upstream’s default, named in the recipe.-DBUILD_THIRDPARTY=OFF— Do not build the copies of zlib, libpng, libtiff and lcms2 that the source tree carries underthirdparty/; the tools link the system libraries instead. Upstream’s default, named.-DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=ON— WithCMAKE_REQUIRE_FIND_PACKAGE_PNG,_TIFFand_LCMS2, stop the configure when one of the tools’ libraries is missing.opj_compressandopj_decompressread and write PNG and TIFF and apply ICC profiles through lcms2, and each library is looked up with afind_packagethat drops its support without an error when it is not found.
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/openjpeg, 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 openjpeg-2.5.4-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/openjpeg, and runs the triggers its paths call for.
Contents
Installed programs: opj_compress, opj_decompress, opj_dump.
Installed libraries: libopenjp2.so.
Installed directories: /usr/include/openjpeg-2.5, /usr/lib/cmake/openjpeg-2.5, /usr/share/licenses/openjpeg.
Short descriptions
opj_compress |
This program reads in an image of a certain type and converts it to a jpeg2000 file. It is part of the OpenJPEG library. Valid input image extensions are .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif . For PNG resp. TIF it needs libpng resp. libtiff . Valid output image extensions are .j2k, .jp2 |
opj_decompress |
This program reads in a jpeg2000 image and converts it to another image type. It is part of the OpenJPEG library. Valid input image extensions are .j2k, .jp2, .j2c, .jpt Valid output image extensions are .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif . For PNG resp. TIF it needs libpng resp. libtiff . |
opj_dump |
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library. Valid input image extensions are .j2k, .jp2, .jpt |
libopenjp2.pc |
JPEG2000 library (Part 1 and 2) |
Notes
CMake installs the manual pages only under BUILD_DOC, an option that otherwise only adds a doc target for the Doxygen HTML reference. build.sh leaves it off and copies the three tool pages and libopenjp2(3) from doc/man itself.