Decoder options; see JxlDecoderOptions. The wasm is initialized lazily on the first decode call, not in the constructor.
Decode one complete JPEG XL byte stream to RGBA8 pixels.
The whole JPEG XL file as raw bytes (a bare codestream or a
.jxl container). Element count equals byte count.
The decoded JxlImageData: RGBA8 pixels (width * height * 4
bytes) plus width/height in pixels and the alpha metadata.
If the stream uses a feature the vendored decoder does not support
yet — multi-layer / blend-mode frame compositing, or non-colour extra
channels (CMYK Black, spot colour). These surface as a wasm RuntimeError
rather than a typed error; the decoder stays usable afterwards.
Browser/Node JPEG XL decoder over the vendored pure-Rust
turbojxlwasm (no emscripten). Decodes a JPEG XL byte stream to RGBA8 pixels.Remarks
Measured against the ISO/IEC 18181-3 conformance corpus,
turbojxldecodes VarDCT and modular streams, greyscale, 8- to 32-bit samples, alpha (premultiplied and straight), patches, splines, noise, progressive, upsampling, JPEG-recompressed streams, and the first frame of an animation. It is not complete: streams built from multi-layer / blend-mode frame compositing, or carrying non-colour extra channels (CMYKBlack, spot colour), reject (see decode). The half of that matrix that fits in the repo is asserted injxl-conformance.test.ts. By default decode is single-threaded and runs everywhere (browsers + Node/Bun); pass JxlDecoderOptions.threads to opt into multithreaded decode on a cross-origin-isolated page. The wasm is initialized lazily on the first decode call and reused across decoders that share the same mode.Example
Example