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.
```rust let mut decoder = decoder_builder().build()?;
// Use multithread use jpegxlrs::ThreadsRunner; let runner = ThreadsRunner::default(); let mut decoder = decoderbuilder() .parallel_runner(&runner) .build()?;
// Customize pixel format let mut decoder = decoderbuilder() .numchannels(3) .endian(Endianness::Big) .align(8) .build()?;
// Set custom memory manager use jpegxlrs::memory::MallocManager; let manager = MallocManager::default(); let mut decoder = decoderbuilder() .memory_manager(&manager) .build()?; ```
rust
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
rust
let mut encoder = encoder_builder()
.lossless(true)
.speed(EncoderSpeed::Falcon)
.build()?;
// You can change the settings after initialization
encoder.set_lossless(false);
encoder.set_quality(3.0);
image
crate integrationThe integration is enabled by default. If you don't need it, use without-image
feature.
```rust use jpegxl_rs::image::*; use image::DynamicImage;
let sample = std::fs::read("test/sample.jxl")?;
let decoder: JxlImageDecoder
License: GPL-3.0-or-later