pub fn decode(data: &[u8]) -> Result<JxlImage>Expand description
Decode a JXL image from a byte slice to RGBA u8 pixels.
For grayscale images, returns GrayAlpha u8 (2 channels). For color images, returns RGBA u8 (4 channels). Alpha is always included; images without alpha get opaque (255) alpha.
Decodes only the first frame. For animation support, use the
JxlDecoder streaming API.
Uses default security limits and parallel decoding (if the threads
feature is enabled). For custom limits or cancellation, use
decode_with.
ยงExample
let data = std::fs::read("photo.jxl").unwrap();
let image = zenjxl_decoder::decode(&data).unwrap();
assert_eq!(image.data.len(), image.width * image.height * image.channels);