Skip to content

JPEG XL image format reference implementation

License

Notifications You must be signed in to change notification settings

jan-wassenberg/libjxl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

JPEG XL reference implementation

Build/Test Build/Test Cross Conformance CIFuzz Releases Doc codecov

JXL logo

This repository contains a reference implementation of JPEG XL (encoder and decoder), called libjxl. This software library is used by many applications that support JPEG XL.

JPEG XL was standardized in 2022 as ISO/IEC 18181. The core codestream is specified in 18181-1, the file format in 18181-2. Decoder conformance is defined in 18181-3, and 18181-4 is the reference software.

The library API, command line options, and tools in this repository are subject to change, however files encoded with cjxl conform to the JPEG XL specification and can be decoded with current and future djxl decoders or libjxl decoding library.

Compilation

For more details and other workflows see the "Advanced guide" below.

Checking out the code

git clone https://github.com/libjxl/libjxl.git --recursive --shallow-submodules

This repository uses git submodules to handle some third party dependencies under third_party, that's why is important to pass --recursive. If you didn't check out with --recursive, or any submodule has changed, run:

git submodule update --init --recursive --depth 1 --recommend-shallow

The --shallow-submodules and --depth 1 --recommend-shallow options create shallow clones which only downloads the commits requested, and is all that is needed to build libjxl. Should full clones be necessary, you could always run:

git submodule foreach git fetch --unshallow
git submodule update --init --recursive

which pulls the rest of the commits in the submodules.

Important: If you downloaded a zip file or tarball from the web interface you won't get the needed submodules and the code will not compile. You can download these external dependencies from source running ./deps.sh. The git workflow described above is recommended instead.

Installing dependencies

Required dependencies for compiling the code, in a Debian/Ubuntu based distribution run:

sudo apt install cmake pkg-config libbrotli-dev

Optional dependencies for supporting other formats in the cjxl/djxl tools, in a Debian/Ubuntu based distribution run:

sudo apt install libgif-dev libjpeg-dev libopenexr-dev libpng-dev libwebp-dev

We recommend using a recent Clang compiler (version 7 or newer), for that install clang and set CC and CXX variables.

sudo apt install clang
export CC=clang CXX=clang++

Building

cd libjxl
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF ..
cmake --build . -- -j$(nproc)

The encoder/decoder tools will be available in the build/tools directory.

Installing

sudo cmake --install .

Usage

To encode a source image to JPEG XL with default settings:

build/tools/cjxl input.png output.jxl

The desired visual fidelity can be selected using the --distance parameter (in units of just-noticeable difference, where 0 is lossless and the most useful lossy range is 0.5 .. 3.0), or using --quality (on a scale from 0 to 100, roughly matching libjpeg). The encode effort can be selected using the --effort parameter.

For more settings run build/tools/cjxl --help or for a full list of options run build/tools/cjxl -v -v --help.

To decode a JPEG XL file run:

build/tools/djxl input.jxl output.png

When possible cjxl/djxl are able to read/write the following image formats: .exr, .gif, .jpeg/.jpg, .pfm, .pgm/.ppm, .pgx, .png. Specifically for JPEG files, the default cjxl behavior is to apply lossless recompression and the default djxl behavior is to reconstruct the original JPEG file.

Benchmarking

For speed benchmarks on single images in single or multi-threaded decoding djxl can print decoding speed information. See djxl --help for details on the decoding options and note that the output image is optional for benchmarking purposes.

For more comprehensive benchmarking options, see the benchmarking guide.

Library API

Besides the libjxl library API documentation, there are example applications and plugins that can be used as a reference or starting point for developers who wish to integrate libjxl in their project.

Advanced guide

Building with Docker

We build a common environment based on Debian/Ubuntu using Docker. Other systems may have different combinations of versions and dependencies that have not been tested and may not work. For those cases we recommend using the Docker container as explained in the step by step guide.

Building JPEG XL for developers

For experienced developers, we provide build instructions for several other environments:

If you encounter any difficulties, please use Docker instead.

License

This software is available under a 3-clause BSD license which can be found in the LICENSE file, with an "Additional IP Rights Grant" as outlined in the PATENTS file.

Please note that the PATENTS file only mentions Google since Google is the legal entity receiving the Contributor License Agreements (CLA) from all contributors to the JPEG XL Project, including the initial main contributors to the JPEG XL format: Cloudinary and Google.

Additional documentation

Codec description

Development process

Contact

If you encounter a bug or other issue with the software, please open an Issue here.

There is a subreddit about JPEG XL, and informal chatting with developers and early adopters of libjxl can be done on the JPEG XL Discord server.

About

JPEG XL image format reference implementation

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 88.8%
  • C 4.1%
  • Python 2.5%
  • Shell 2.0%
  • CMake 1.8%
  • JavaScript 0.3%
  • Other 0.5%