jpegxl-rs
jpegxl-rs
is a safe wrapper over jpeg-xl
library. Check out the original library
and the bindings.
Building
The library build jpeg-xl
and link to libc++
by default. Optionally, you can set --features without-build
, then
set the include path and lib path with DEP_JXL_INCLUDE
and DEP_JXL_LIB
respectively.
If you don't want to depend on C++ standard library, use --features without-threads
to disable default threadpool.
Instead, you can enable with-rayon
feature to use its threadpool.
You need to have a working llvm
environment.
Usage
Decoding
use *;
let sample = read?;
let mut decoder: = decoder_builder.build?;
let = decoder.decode?;
Set output pixel paramaters
// Pixel type is set by type parameter
let mut decoder: = decoder_builder
.num_channel
.endianness
.align
.build?;
Encoding
use *;
use Reader as ImageReader;
let sample = open?.decode?.to_rgba16;
let mut encoder = encoder_builder.build?;
let buffer: = encoder.encode?;
image
crate integration
The integration is enabled by default. If you don't need it, use without-image
feature.
use *;
use DynamicImage;
let sample = read?;
let decoder: = new?;
let img = from_decoder?;