By default the encoder assumes no metadata boxes will be added according to libjxl's API. So metadata like EXIF data is missing when creating jxl from png image etc.
An example code to encode with EXIF data:
use std::io::Write;
use jpegxl_rs::encode::{EncoderResult, BoxTypes};
use jpegxl_rs::encoder_builder;
use image::io::Reader as ImageReader;
fn main() {
let sample = ImageReader::open("sample.png").unwrap().decode().unwrap().to_rgb8();
let mut encoder = encoder_builder().build().unwrap();
let file = std::fs::File::open("sample.png").unwrap();
let mut bufreader = std::io::BufReader::new(&file);
let exifreader = exif::Reader::new();
let exif = exifreader.read_from_container(&mut bufreader).unwrap();
let buffer: EncoderResult<f32> = encoder.encode_with_box(&sample, sample.width(), sample.height(), exif.buf(), BoxTypes::Exif).unwrap();
let mut file = std::fs::File::create("sample.jxl").unwrap();
let _ = file.write(&buffer.data);
}
encode_with_box
to encode image with metadataBy default the encoder assumes no metadata boxes will be added according to libjxl's API. So metadata like EXIF data is missing when creating
jxl
from png image etc.An example code to encode with EXIF data: