jpegxl-rs
A safe JPEGXL wrapper over libjxl
library. Check out the original library
and the bindings.
Building
If you wish to specify a custom library path, set the DEP_JXL_LIB
environment variable.
Building libjxl
and statically linking can be enabled by using the vendored
feature.
If you don't want to depend on C++ standard library, disable the feature threads
.
Usage
Currently, u8
, u16
, f16
and f32
are supported as pixel types.
Decoding
let mut decoder = decoder_builder.build?;
let = decoder.decode?;
match pixels
// Multi-threading
use ThreadsRunner;
let runner = default;
let mut decoder = decoder_builder
.parallel_runner
.build?;
// Customize pixel format
let mut decoder = decoder_builder
.pixel_format
.build?;
decoder.;
// You can change the settings after initialization
decoder.skip_reorientation = Some;
// Reconstruct JPEG, fallback to pixels if JPEG reconstruction is not possible
// This operation is finished in on pass
let = decoder.reconstruct?;
match data
Encoding
use Reader as ImageReader;
let sample = open?.decode?.to_rgba16;
let mut encoder = encoder_builder.build?;
let buffer: = encoder.encode?;
Set encoder options
let mut encoder = encoder_builder
.lossless
.speed
.build?;
// 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
feature.
use ToDynamic;
use decoder_builder;
use DynamicImage;
let sample = read?;
let mut decoder = decoder_builder.build?;
let img = decoder.decode_to_image?;
let img = decoder.?;
License: GPL-3.0-or-later