Crate jpegxl_rs[][src]

Expand description

Documentation CI Coverage Status License: GPL-3.0-or-later

A safe JPEGXL wrapper over jpeg-xl library. Check out the original library and the bindings.


The library build jpeg-xl and link to lib(std)c++ by default. Optionally, you can use system-jxl feature to dynamically link to it. If you don’t have it in the default include and library paths, set them with DEP_JXL_INCLUDE and DEP_JXL_LIB respectively.

If you don’t want to depend on C++ standard library, disable threads feature.


Currently, u8, u16 and f32(partial) are supported as pixel types. u32 is in the header but not implemented.

Note: f32 with alpha channel is not supported in encoder.


let mut decoder = decoder_builder().build()?;

// Multi-threading
use jpegxl_rs::ThreadsRunner;
let runner = ThreadsRunner::default();
let mut decoder = decoder_builder()

// Customize pixel format
let mut decoder = decoder_builder()


// You can change the settings after initialization
decoder.num_channels = 1;
decoder.endianness = Endianness::Native;


use image::io::Reader as ImageReader;
let sample = ImageReader::open("test/sample.png")?.decode()?.to_rgba16();
let mut encoder = encoder_builder().build()?;
let buffer: EncoderResult<f32> = encoder.encode(&sample, sample.width(), sample.height())?;

Set encoder options

let mut encoder = encoder_builder()
// You can change the settings after initialization
encoder.lossless = false;
encoder.quality = 3.0;

image crate integration

The integration is enabled by default. If you don’t need it, disable image-support feature.

use jpegxl_rs::image::ToDynamic;
use jpegxl_rs::decoder_builder;
use image::DynamicImage;

let sample = std::fs::read("test/sample.jxl")?;
let decoder = decoder_builder().build()?;
let img = decoder.decode(&sample)?.into_dynamic_image();       


pub use decode::decoder_builder;
pub use encode::encoder_builder;
pub use parallel::ThreadsRunner;


Decoder of JPEG XL format

Encoder of JPEG XL format


image crate integration

Memory manager interface

Parallel runner interface


Errors derived from JxlDecoderStatus

Errors derived from JxlEncoderStatus

Type Definitions

Endianness of the pixels