### Install the binaries Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING.md Install the compiled tools to the system. ```bash sudo cmake --install . ``` -------------------------------- ### Reproduce Cross-Compilation Build Locally Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/debugging_workflows.md This snippet outlines the setup and compilation steps for reproducing 'cross' workflows locally within a Docker container. It includes environment variable configuration and package installation. ```bash docker run -it -v`pwd`:/libjxl debian:bookworm bash cd /libjxl export ARCH=i386 # arm64 armhf export MAIN_LIST="amd64,${ARCH}" export BUILD_DIR=build export CC=clang-14 export CXX=clang++-14 export BUILD_TARGET=i686-linux-gnu # aarch64-linux-gnu arm-linux-gnueabihf rm -f /var/lib/man-db/auto-update apt-get update -y apt-get install -y ca-certificates debian-ports-archive-keyring python3 dpkg --add-architecture ${ARCH} python3 ./tools/scripts/transform_sources_list.py "${MAIN_LIST}" apt update apt-get install -y \ clang-14 cmake doxygen g++-aarch64-linux-gnu graphviz libbrotli-dev:${ARCH} \ libc6-dev-${ARCH}-cross libgdk-pixbuf2.0-dev:${ARCH} libgif-dev:${ARCH} \ libgtk2.0-dev:${ARCH} libilmbase-dev:${ARCH} libjpeg-dev:${ARCH} \ libopenexr-dev:${ARCH} libpng-dev:${ARCH} libstdc++-12-dev-${ARCH}-cross \ libstdc++-12-dev:${ARCH} libwebp-dev:${ARCH} ninja-build pkg-config \ qemu-user-static unzip xdg-utils xvfb #apt-get install -y binutils-${BUILD_TARGET} gcc-${BUILD_TARGET} #apt-get install -y \ # libgoogle-perftools-dev:${ARCH} libgoogle-perftools4:${ARCH} \ # libtcmalloc-minimal4:${ARCH} libunwind-dev:${ARCH} #export CMAKE_FLAGS="-march=armv8-a+sve" SKIP_TEST=1 ./ci.sh release \ -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ -DJPEGXL_ENABLE_JNI=OFF # -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static # -DJPEGXL_ENABLE_OPENEXR=off # -DCMAKE_CXX_FLAGS=-DJXL_HIGH_PRECISION=0 ``` -------------------------------- ### Install minimum build dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Install the essential tools and libraries required for building the project on Debian or Ubuntu. ```bash sudo apt install clang cmake doxygen graphviz ninja-build libpng-dev ``` -------------------------------- ### Install a Specific Package Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Install a package, optionally specifying the group. For tools that need compiler awareness, install the version corresponding to your build environment (e.g., `mingw64`). ```bash pacman -S mingw-w64-x86_64-cmake ``` -------------------------------- ### Install MIME package file Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/mime/CMakeLists.txt Installs the image-jxl.xml file to the share/mime/packages/ directory. This is typically part of a build or installation script. ```cmake install(FILES image-jxl.xml DESTINATION share/mime/packages/) ``` -------------------------------- ### Install dependencies with vcpkg Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_vcpkg.md Use these commands to install the required libraries for the JPEG XL project on Windows. ```shell vcpkg install gtest:x64-windows vcpkg install giflib:x64-windows vcpkg install libjpeg-turbo:x64-windows vcpkg install libpng:x64-windows vcpkg install zlib:x64-windows ``` -------------------------------- ### Install Emscripten SDK Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_wasm.md Commands to clone the Emscripten repository and install the latest SDK tools. ```bash cd $OPT # Get the emsdk repo. git clone https://github.com/emscripten-core/emsdk.git # Enter that directory. cd emsdk # Download and install the latest SDK tools. ./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file) ./emsdk activate latest ``` -------------------------------- ### Advanced cjxl Compression Examples Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/man/cjxl.txt Examples demonstrating specific quality and lossless compression settings for various use cases. ```bash # Compress a PNG file to a high-quality JPEG XL version. $ cjxl input.png output.jxl # Compress it at a slightly lower quality, appropriate for web use. $ cjxl -d 2 input.png output.jxl # Compress it losslessly. These are equivalent. $ cjxl -d 0 input.png lossless.jxl $ cjxl -q 100 input.png lossless.jxl # Compress a JPEG file losslessly. $ cjxl input.jpeg lossless-jpeg.jxl ``` -------------------------------- ### Install GIMP packages Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Installs the GIMP package for the specified MSYS2 environment. ```bash pacman -S mingw-w64-i686-gimp pacman -S mingw-w64-x86_64-gimp pacman -S mingw-w64-ucrt-x86_64-gimp ``` -------------------------------- ### Install lint and coverage dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Install necessary packages for running linting and code coverage commands. ```bash sudo apt install clang-format clang-tidy curl parallel gcovr ``` -------------------------------- ### Install build dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING.md Commands to install required and optional system dependencies on Debian/Ubuntu distributions. ```bash sudo apt install cmake pkg-config libbrotli-dev ``` ```bash sudo apt install libgif-dev libjpeg-dev libopenexr-dev libpng-dev libwebp-dev ``` -------------------------------- ### Configure Testing and Installation Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/CMakeLists.txt Includes testing frameworks, configures license file copying, and sets up test data paths. ```cmake include(GNUInstallDirs) include(third_party/testing.cmake) add_subdirectory(third_party) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" ${PROJECT_BINARY_DIR}/LICENSE.jpeg-xl COPYONLY) enable_testing() include(CTest) if(NOT DEFINED JPEGXL_TEST_DATA_PATH) set(JPEGXL_TEST_DATA_PATH "${PROJECT_SOURCE_DIR}/testdata") endif() ``` -------------------------------- ### Install Core Dependencies using Homebrew Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING_OSX.md Install essential libraries and tools required for building JPEG XL, including core utilities, CMake, and image format libraries. ```bash brew install coreutils cmake giflib jpeg-turbo libpng ninja zlib ``` -------------------------------- ### Install UglifyJS Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/wasm_demo/README.md Install uglify-js globally using npm. This is a dependency for the `build_site.py` script. ```bash npm install uglify-js -g ``` -------------------------------- ### Install clang compiler packages Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Lists the required packages for installing the clang compiler in different MSYS2 environments. ```text mingw-w64-i686-clang mingw-w64-i686-clang-tools-extra mingw-w64-i686-clang-compiler-rt mingw-w64-x86_64-clang mingw-w64-x86_64-clang-tools-extra mingw-w64-x86_64-clang-compiler-rt mingw-w64-ucrt64-x86_64-clang mingw-w64-ucrt64-x86_64-clang-tools-extra mingw-w64-ucrt64-x86_64-clang-compiler-rt ``` -------------------------------- ### Set up MING64 Environment Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Install essential development tools and libraries for the MING64 environment. The `--needed` flag prevents reinstallation of already present packages. ```bash pacman -S --needed base-devel mingw-w64-x86_64-toolchain pacman -S git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja \ mingw-w64-x86_64-gtest mingw-w64-x86_64-giflib \ mingw-w64-x86_64-libpng mingw-w64-x86_64-libjpeg-turbo ``` -------------------------------- ### Install optional build dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Install additional packages required for compiling extra tools and tests. ```bash sudo apt install extra-cmake-modules g++ libbenchmark-dev libbenchmark-tools \ libgif-dev libgoogle-perftools-dev libgtest-dev libjpeg-dev libopenexr-dev \ libwebp-dev qt6-base-dev xdg-utils ``` -------------------------------- ### Configure Clang compiler Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING.md Install Clang and set environment variables for the build process. ```bash sudo apt install clang export CC=clang CXX=clang++ ``` -------------------------------- ### Install JXL Thumbnailer Manually Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/README.md Copy the thumbnailer configuration file to the system thumbnailers directory. ```bash sudo cp plugins/gdk-pixbuf/jxl.thumbnailer /usr/local/share/thumbnailers/jxl.thumbnailer ``` -------------------------------- ### Install JPEG XL using Homebrew Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING_OSX.md Use this command to install the JPEG XL library and binaries via Homebrew. ```bash brew install jpeg-xl ``` -------------------------------- ### Install Crossroad Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Installs the Crossroad tool itself using pip. ```bash pip3 install crossroad ``` -------------------------------- ### Install gtest and brotli Dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Installs the gtest and brotli packages, which are also required for building libjxl. ```bash crossroad install gtest brotli ``` -------------------------------- ### Install GIMP Development Package Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Installs the GIMP development package, which includes most dependencies required for building the GIMP plugin and libjxl. ```bash crossroad install gimp ``` -------------------------------- ### Build libjxl with clang Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Uses the ci.sh script to build libjxl when clang is installed. ```bash ./ci.sh opt -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF \ -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_MANPAGES=OFF \ -DJPEGXL_FORCE_SYSTEM_BROTLI=ON -DJPEGXL_FORCE_SYSTEM_GTEST=ON ``` -------------------------------- ### Install JPEG XL Library Headers Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/lib/CMakeLists.txt Installs all JPEG XL library headers, both source and generated, into the binary directory to the specified include path. ```cmake install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/jxl DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ``` -------------------------------- ### Install Gdk-Pixbuf JPEG XL Loader Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/CMakeLists.txt Installs the `pixbufloader-jxl` target to the determined Gdk-Pixbuf module directory. ```cmake install(TARGETS pixbufloader-jxl DESTINATION "${GDK_PIXBUF_MODULEDIR}") ``` -------------------------------- ### Install llvm-symbolizer Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_and_testing.md Installs the llvm-symbolizer tool on Debian-based systems, which is helpful for obtaining symbolic stack traces during MSan checks. ```bash sudo apt install llvm # or llvm-7, etc for a specific version. ``` -------------------------------- ### Install Crossroad Dependencies Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Installs essential tools like python3-docutils and mingw-w64 required for Crossroad. ```bash sudo aptitude install python3-docutils mingw-w64 ``` -------------------------------- ### Install LLVM using Homebrew Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING_OSX.md Install the LLVM compiler suite, which may take a significant amount of time. Ensure XCode is up-to-date and brew doctor reports no serious issues before proceeding. ```bash brew install llvm ``` -------------------------------- ### Start New Branch Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_github.md Create a new local branch named 'mybranch' that tracks the 'origin/main' branch. This is the recommended way to start working on a new feature or fix. ```bash git checkout origin/main -b mybranch ``` -------------------------------- ### Configure CMake for libjxl Examples Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/examples/CMakeLists.txt This CMake script sets up the build environment for libjxl examples. It requires CMake version 3.16 or higher and uses pkg-config to locate the libjxl, libjxl_cms, and libjxl_threads libraries. ```cmake cmake_minimum_required(VERSION 3.16) project(SAMPLE_LIBJXL LANGUAGES C CXX) # Use pkg-config to find libjxl. find_package(PkgConfig) pkg_check_modules(Jxl REQUIRED IMPORTED_TARGET libjxl libjxl_cms libjxl_threads) ``` ```cmake # Build the example encoder/decoder binaries using the default shared libraries # installed. add_executable(decode_exif_metadata decode_exif_metadata.cc) target_link_libraries(decode_exif_metadata PkgConfig::Jxl) ``` ```cmake add_executable(decode_oneshot decode_oneshot.cc) target_link_libraries(decode_oneshot PkgConfig::Jxl) ``` ```cmake add_executable(decode_progressive decode_progressive.cc) target_link_libraries(decode_progressive PkgConfig::Jxl) ``` ```cmake add_executable(encode_oneshot encode_oneshot.cc) target_link_libraries(encode_oneshot PkgConfig::Jxl) ``` -------------------------------- ### Install zstandard Python Package Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Installs the zstandard Python package using pip, as it's not available in standard repositories. ```bash pip3 install zstandard ``` -------------------------------- ### Install JPEG XL Thumbnailer Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/CMakeLists.txt Installs the `jxl.thumbnailer` file to the system's thumbnailers directory. This allows Gdk-Pixbuf to generate thumbnails for JPEG XL images. ```cmake # Instead of the following, we might instead add the # mime type image/jxl to # /usr/share/thumbnailers/gdk-pixbuf-thumbnailer.thumbnailer install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/jxl.thumbnailer DESTINATION "${CMAKE_INSTALL_DATADIR}/thumbnailers/") ``` -------------------------------- ### Install JPEG XL Build Dependencies on Haiku Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING_Haiku.md Installs necessary build tools and libraries for JPEG XL using the Haiku package manager. Ensure you have `pkgman` available. ```shell pkgman install llvm9_clang ninja cmake doxygen libjpeg_turbo_devel giflib_devel ``` -------------------------------- ### Install GDK Pixbuf Loader Manually Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/README.md Copy the compiled plugin library to the system GDK Pixbuf loaders directory. ```bash sudo cp $your_build_directory/plugins/gdk-pixbuf/libpixbufloader-jxl.so /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jxl.so ``` -------------------------------- ### Configure CMakeSettings.json for Clang Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_vcpkg.md Configuration file for Visual Studio to enable the x64-Clang build environment. Replace $VCPKG with your local vcpkg installation path. ```json { "configurations": [ { "name": "x64-Clang-Release", "generator": "Ninja", "configurationType": "MinSizeRel", "buildRoot": "${projectDir}\\out\\build\\${name}", "installRoot": "${projectDir}\\out\\install\\${name}", "cmakeCommandArgs": "-DCMAKE_TOOLCHAIN_FILE=$VCPKG/scripts/buildsystems/vcpkg.cmake", "buildCommandArgs": "-v", "ctestCommandArgs": "", "inheritEnvironments": [ "clang_cl_x64" ], "variables": [ { "name": "VCPKG_TARGET_TRIPLET", "value": "x64-windows", "type": "STRING" }, { "name": "JPEGXL_ENABLE_TCMALLOC", "value": "False", "type": "BOOL" }, { "name": "gtest_force_shared_crt", "value": "True", "type": "BOOL" }, { "name": "JPEGXL_ENABLE_FUZZERS", "value": "False", "type": "BOOL" }, { "name": "JPEGXL_ENABLE_VIEWERS", "value": "False", "type": "BOOL" } ] } ] } ``` -------------------------------- ### Install JPEG XL MIME type Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/mime/README.md Manually install the JPEG XL MIME type definition using the xdg-mime command. This requires root privileges. ```bash sudo xdg-mime install --novendor image-jxl.xml ``` -------------------------------- ### Build Project with MSan Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_and_testing.md Builds the project with Memory Sanitizer (MSan) enabled. This command assumes MSan-compatible libc++ has been installed using './ci.sh msan_install'. ```bash ./ci.sh msan ``` -------------------------------- ### Check clang version Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Verify the installed version of the clang compiler. ```bash clang --version ``` -------------------------------- ### Example Git Push Output Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_github.md This output shows the result of pushing a new branch to a remote repository, including object enumeration, compression, and the URL for creating a pull request. ```text Enumerating objects: 627, done. Counting objects: 100% (627/627), done. Delta compression using up to 56 threads Compressing objects: 100% (388/388), done. Writing objects: 100% (389/389), 10.71 MiB | 8.34 MiB/s, done. Total 389 (delta 236), reused 0 (delta 0) remote: remote: Create a pull request for 'mybranch' on GitHub by visiting: remote: https://github.com/{{USERNAME}}/libjxl/pull/new/mybranch remote: To github.com:{{USERNAME}}/libjxl.git * [new branch] mybranch -> mybranch ``` -------------------------------- ### Setup tmate Session in GitHub Actions Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/debugging_workflows.md Add this snippet to a GitHub workflow to set up a tmate session for debugging. It's conditional on failure and has a timeout. ```yaml - name: Setup tmate session # Or other condition that pin-points a single strategy matrix item if: failure() uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # v3.17 timeout-minutes: 15 ``` -------------------------------- ### Encode Image with Custom HEVC Codec Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/benchmark/hm/README.md Example usage for encoding an image using the custom HEVC codec with a specified QP value. Ensure the paths to the encode and decode scripts are correctly set. ```bash tools/benchmark_xl --input=image.png --codec='custom:bin:.../tools/benchmark/hm/encode.sh:.../tools/benchmark/hm/decode.sh:-q:30' ``` -------------------------------- ### Build the Demo Site Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/wasm_demo/README.md Execute the `build_site.py` script to compile the demo site. Provide source, binary, and output paths as arguments. ```bash python3 ./tools/wasm_demo/build_site.py ./tools/wasm_demo/ ./build-wasm32/tools/wasm_demo/ /path/to/demo-site ``` -------------------------------- ### Build and test the project Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Execute the build script to compile the project and run unit tests. ```bash ./ci.sh opt ``` -------------------------------- ### Build the project Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING.md Standard CMake build sequence for compiling the library and tools. ```bash cd libjxl mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF .. cmake --build . -- -j$(nproc) ``` -------------------------------- ### Create New Crossroad Project for Windows Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_with_crossroad.md Initializes a new Crossroad project for 64-bit Windows cross-compilation. Replace `[project-name]` with your desired project name. ```bash crossroad w64 [project-name] ``` -------------------------------- ### Build JPEG XL Software and Run Unit Tests Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_and_testing.md Use this command to build the JPEG XL software and execute its unit tests. Ensure the build environment is set up prior to execution. ```bash ./ci.sh release ``` -------------------------------- ### Build and run using Docker Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_debian.md Build the project inside a Docker container using the provided Dockerfile and execute the release build script. ```bash docker build . -f .devcontainer/Dockerfile -t libjxl docker run --mount type=bind,src=.,dst=/workspaces/libjxl -i libjxl ./ci.sh release ``` -------------------------------- ### Clone the repository Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING.md Initial checkout of the libjxl repository including submodules. ```bash git clone https://github.com/libjxl/libjxl.git --recursive --shallow-submodules ``` -------------------------------- ### Configure libjxl build with CMake Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Initializes the build directory and configures the project using CMake with specific build flags. ```bash mkdir build cd build cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF \ -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_PLUGINS=ON \ -DJPEGXL_ENABLE_MANPAGES=OFF -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ -DJPEGXL_FORCE_SYSTEM_GTEST=ON .. ``` -------------------------------- ### Clone and Configure JPEG XL Repository Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_github.md Clone the JPEG XL repository and set up remote repositories for upstream and your fork. Replace {{USERNAME}} with your GitHub username. 'origin' will point to the upstream repository for fetching, and your fork for pushing. 'myfork' is an optional remote for your fork. ```bash git clone https://github.com/libjxl/libjxl --recursive cd libjxl git remote set-url --push origin git@github.com:{{USERNAME}}/libjxl.git git remote add myfork git@github.com:{{USERNAME}}/libjxl.git git remote -vv ``` -------------------------------- ### Update GDK Pixbuf Loader Cache Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/README.md Refresh the loader cache to register the newly installed plugin. ```bash sudo /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache ``` -------------------------------- ### Update MIME database Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/mime/README.md After installing or uninstalling MIME type definitions, run this command to update the local MIME database. ```bash update-mime --local ``` -------------------------------- ### Download a JPEG XL sample file Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/mime/README.md Use wget to download a sample JPEG XL file for testing MIME type recognition. ```bash wget https://raw.githubusercontent.com/libjxl/conformance/master/testcases/bicycles/input.jxl ``` -------------------------------- ### Set Pkg-config Target Libraries Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/lib/CMakeLists.txt Determines the installation directory for pkg-config target libraries based on whether CMAKE_INSTALL_LIBDIR is an absolute path. ```cmake if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_LIBDIR}") else() set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### List All Available Tests Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_and_testing.md Use this command to list all the tests that can be run. Arguments passed to './ci.sh test' are forwarded to 'ctest'. ```bash ./ci.sh test -N ``` -------------------------------- ### Set Pkg-config Target Includes Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/lib/CMakeLists.txt Determines the installation directory for pkg-config target includes based on whether CMAKE_INSTALL_INCLUDEDIR is an absolute path. ```cmake if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}") else() set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") endif() ``` -------------------------------- ### Run benchmark_xl compression comparison Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/benchmarking.md Executes a benchmark comparing JXL encoding settings across a set of input images. ```bash build/tools/benchmark_xl --input "/path/*.png" --codec jxl:wombat:d1,jxl:cheetah:d2 ``` -------------------------------- ### Determine Gdk-Pixbuf Module Directory Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/CMakeLists.txt Executes `pkg-config` to find the `gdk_pixbuf_moduledir` variable, which is necessary for correctly installing the plugin. The output is stripped of trailing whitespace. ```cmake execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gdk-pixbuf-2.0 --variable gdk_pixbuf_moduledir --define-variable=prefix=${CMAKE_INSTALL_PREFIX} OUTPUT_VARIABLE GDK_PIXBUF_MODULEDIR OUTPUT_STRIP_TRAILING_WHITESPACE) ``` -------------------------------- ### Build WASM artifacts Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_wasm.md Commands to configure the environment and build the project with or without SIMD support. ```bash # Setup EMSDK and other environment variables. In practice EMSDK is set to be # $OPT/emsdk. source $OPT/emsdk/emsdk_env.sh # This should set the $EMSDK variable. # If your node version is <16.4.0, you might need to update to a newer version or override # the node binary with a version which supports SIMD: echo "NODE_JS='/path/to/node_binary'" >> $EMSDK/.emscripten # Assuming you are in the root level of the cloned libjxl repo, # either build with regular WASM: BUILD_TARGET=wasm32 emconfigure ./ci.sh release # or with SIMD WASM: BUILD_TARGET=wasm32 ENABLE_WASM_SIMD=1 emconfigure ./ci.sh release ``` -------------------------------- ### Handle Missing Doxygen Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/CMakeLists.txt Issues a warning if Doxygen or Dot is not installed, indicating that the 'doc' target will fail. A dummy 'doc' target is created for compatibility. ```cmake message(WARNING "Doxygen or Dot not installed; 'doc' target will FAIL") # Create a "doc" target for compatibility since "doc" is not otherwise added # to the build when doxygen is not installed. add_custom_target(doc false COMMENT "Error: Can't generate doc since Doxygen or Dot not installed.") ``` -------------------------------- ### Configure Gdk Test Environment Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/plugins/gdk-pixbuf/CMakeLists.txt Sets up the testing environment for the Gdk-Pixbuf loader. This includes checking for Gdk development libraries and the `xdg-mime` utility. It also creates a MIME cache for testing. ```cmake if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING) pkg_check_modules(Gdk IMPORTED_TARGET gdk-2.0) if (Gdk_FOUND) # Test for loading a .jxl file using the pixbufloader library via GDK. This # requires to have the image/jxl mime type and loader library configured, # which we do in a fake environment in the CMAKE_CURRENT_BINARY_DIR. add_executable(pixbufloader_test pixbufloader_test.cc) target_link_libraries(pixbufloader_test PkgConfig::Gdk) find_program(XDG_MIME_PROGRAM xdg-mime) if (NOT XDG_MIME_PROGRAM) message(WARNING "xdg-mime is required for testing pixbufloader; consider installing xdg-utils package") return() endif() # Create a mime cache for test. add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mime/mime.cache" COMMAND env XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR} xdg-mime install --novendor "${CMAKE_SOURCE_DIR}/plugins/mime/image-jxl.xml" DEPENDS "${CMAKE_SOURCE_DIR}/plugins/mime/image-jxl.xml" ) add_custom_target(pixbufloader_test_mime DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/mime/mime.cache" ) add_dependencies(pixbufloader_test pixbufloader_test_mime) # Use a fake X server to run the test if xvfb is installed. find_program (XVFB_PROGRAM xvfb-run) if(XVFB_PROGRAM) set(XVFB_PROGRAM_PREFIX "${XVFB_PROGRAM};-a") else() set(XVFB_PROGRAM_PREFIX "") endif() # libX11.so and libgdk-x11-2.0.so are not compiled with MSAN -> report # use-of-uninitialized-value for string some internal string value. # TODO(eustas): investigate direct memory leak (32 bytes). if (NOT (SANITIZER STREQUAL "msan") AND NOT (SANITIZER STREQUAL "asan")) add_test( NAME pixbufloader_test_jxl COMMAND ${XVFB_PROGRAM_PREFIX} $ "${CMAKE_CURRENT_SOURCE_DIR}/loaders_test.cache" "${JPEGXL_TEST_DATA_PATH}/jxl/blending/cropped_traffic_light.jxl" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) set_tests_properties(pixbufloader_test_jxl PROPERTIES SKIP_RETURN_CODE 254) endif() endif() # Gdk_FOUND endif() # BUILD_TESTING ``` -------------------------------- ### Probe Multithreading Support Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/wasm_demo/manual_decode_demo.html Checks if the environment supports multithreading by attempting to create a SharedArrayBuffer. Logs a message if Service Workers are being installed, indicating potential restrictions. ```javascript let probeMultithreading = () => { try { new SharedArrayBuffer(); return true; } catch (ex) { addMessage('Installing Service Worker, please wait...', 'orange'); return false; } }; ``` -------------------------------- ### Build oss-fuzz libjxl Docker Image Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/fuzzing.md Clone the oss-fuzz repository and use the helper script to build the Docker image for libjxl fuzzing. This image includes necessary dependencies for fuzzing. ```bash git clone https://github.com/google/oss-fuzz.git ~/oss-fuzz cd ~/oss-fuzz sudo infra/helper.py build_image libjxl ``` -------------------------------- ### Create a Release Branch Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/release.md Use this command to create a new release branch from the latest commit in 'origin/main'. Replace 'v0.5.x' with your desired branch name and 'origin/main' with a specific commit SHA if needed. ```bash git fetch origin main git push git@github.com:libjxl/libjxl.git origin/main:refs/heads/v0.5.x ``` -------------------------------- ### Build Downstream Projects with Docker Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/release.md Builds libjxl, ImageMagick, and FFmpeg within a Debian Docker container, enabling jpeg-xl support for each. Installs necessary dependencies and configures build options. ```bash docker run -it debian:bookworm /bin/bash apt update apt install -y clang cmake git libbrotli-dev nasm pkg-config ninja-build export CC=clang export CXX=clang++ ``` ```bash mkdir -p /src cd /src git clone --recurse-submodules --depth 1 -b v0.9.x \ https://github.com/libjxl/libjxl.git git clone --recurse-submodules --depth 1 \ https://github.com/ImageMagick/ImageMagick.git git clone --recurse-submodules --depth 1 \ https://github.com/FFmpeg/FFmpeg.git ``` ```bash cd /src/libjxl cmake -B build -G Ninja . cmake --build build -j`nproc` cmake --install build --prefix="/usr" ``` ```bash cd /src/ImageMagick ./configure --with-jxl=yes # check for "JPEG XL --with-jxl=yes yes" make -j `nproc` ./utilities/magick -version ``` ```bash cd /src/FFmpeg ./configure --disable-all --disable-debug --enable-avcodec --enable-avfilter \ --enable-avformat --enable-libjxl --enable-encoder=libjxl \ --enable-decoder=libjxl --enable-ffmpeg # check for libjxl decoder/encoder support make -j `nproc` ldd ./ffmpeg ./ffmpeg -version ``` -------------------------------- ### Configure CMAKE_PREFIX_PATH for Build Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/BUILDING_OSX.md Set the CMAKE_PREFIX_PATH environment variable to ensure correct include path resolution for dependencies installed via Homebrew. This is crucial if the system's default clang is not being used. ```bash export CMAKE_PREFIX_PATH=`brew --prefix giflib`:`brew --prefix jpeg-turbo`:`brew --prefix libpng`:`brew --prefix zlib` ``` -------------------------------- ### JPEG XL Configuration Parameters Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/example_tree.txt Initial settings for image dimensions, bit depth, and color transformation. ```text RCT 6 /* YCoCg */ GroupShift 3 /* Group size is 128 << 3 == 1024 */ Width 1024 Height 1024 Bitdepth 8 /* FloatExpBits 3 */ /* Alpha */ /* Squeeze */ /* XYB */ /* CbYCr */ ``` -------------------------------- ### Cross-Compile for a Different Architecture Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/building_and_testing.md Compile the code for an architecture different from the current one. This requires a pre-configured cross-compiling environment and installed library dependencies for the target. The BUILD_TARGET environment variable specifies the target triplet. ```bash BUILD_TARGET=aarch64-linux-gnu ./ci.sh release ``` -------------------------------- ### Basic cjxl Compression Commands Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/man/cjxl.txt Standard commands for compressing common image formats to JPEG XL using default settings. ```bash cjxl input.png output.jxl cjxl input.jpg output.jxl cjxl input.gif output.jxl ``` -------------------------------- ### Run Fuzzer Targets Locally Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/fuzzing.md Execute fuzzer targets in fuzzing mode. Running with no parameters starts fuzzing, while providing a directory path uses it as a seed corpus. Use `-help=1` for detailed options. ```bash build-fuzzmsan/tools/djxl_fuzzer -help=1 ``` -------------------------------- ### Configure JNI Wrapper Library with CMake Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/CMakeLists.txt This CMake configuration sets up a shared library for the JPEG XL JNI wrapper. It finds JNI and Java packages, links necessary libraries, and installs the JNI library. ```cmake if(JPEGXL_ENABLE_JNI) find_package(JNI QUIET) find_package(Java QUIET) if (JNI_FOUND AND Java_FOUND) include(UseJava) # NB: *_jni_onload.cc might be necessary for Android; not used yet. # JPEGXL wrapper add_library(jxl_jni SHARED jni/org/jpeg/jpegxl/wrapper/decoder_jni.cc) target_include_directories(jxl_jni PRIVATE "${JNI_INCLUDE_DIRS}" "${PROJECT_SOURCE_DIR}") target_link_libraries(jxl_jni PUBLIC jxl_dec-internal jxl_threads) if(NOT DEFINED JPEGXL_INSTALL_JNIDIR) set(JPEGXL_INSTALL_JNIDIR ${CMAKE_INSTALL_LIBDIR}) endif() install(TARGETS jxl_jni DESTINATION ${JPEGXL_INSTALL_JNIDIR}) ``` -------------------------------- ### Configure Static Build Settings Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/CMakeLists.txt Configures linker flags and runtime library settings for static builds. ```cmake if(JPEGXL_STATIC) set(BUILD_SHARED_LIBS 0) # https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170 # https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html # For debug builds we intentionally link with shared library to ensure that we don’t accidentally # redistribute such binaries anywhere. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:DebugDLL>" CACHE STRING "") # Clang developers say that in case to use "static" we have to build stdlib # ourselves; for real use case we don't care about stdlib, as it is "granted", # so just linking all other libraries is fine. if (NOT MSVC AND NOT APPLE) string(APPEND CMAKE_EXE_LINKER_FLAGS " -static") endif() if ((NOT WIN32 AND NOT APPLE) OR CYGWIN OR MINGW) set(CMAKE_FIND_LIBRARY_SUFFIXES .a) string(APPEND CMAKE_EXE_LINKER_FLAGS " -static-libgcc -static-libstdc++") endif() endif() # JPEGXL_STATIC ``` -------------------------------- ### Determine JPEG XL Version from Git Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/tools/CMakeLists.txt This CMake code determines the JPEG XL version from the Git commit hash if not explicitly defined. It uses `execute_process` to get the short commit hash and sets `JPEGXL_VERSION` accordingly. ```cmake if(NOT DEFINED JPEGXL_VERSION OR JPEGXL_VERSION STREQUAL "") find_package(Git QUIET) execute_process( COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD OUTPUT_VARIABLE GIT_REV WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ERROR_QUIET) string(STRIP "${GIT_REV}" GIT_REV) if(GIT_REV STREQUAL "") set(JPEGXL_VERSION "(unknown)") endif() endif() ``` -------------------------------- ### Reconfigure and build GIMP plugin Source: https://gitlab.com/wg1/jpeg-xl/-/blob/main/doc/developing_in_windows_msys.md Cleans the build directory and reconfigures the project to include the GIMP plugin. ```bash cd build rm -r CM* cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF \ -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_MANPAGES=OFF \ -DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ -DJPEGXL_FORCE_SYSTEM_GTEST=ON .. ```