Export the capture as JPEG XL.
Adds toJxl(), toBlob({ format: 'jxl' }) and download({ format: 'jxl' }). Text and interface stay exact while photos take the quality, in one JPEG XL file. The encoder is rapier-jxl (MIT), an optional peer: the text measurement loads at the first capture, the encoder at the first export.
npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latestnpm install rapier-jxl
Usage
import { snapdom } from '@zumer/snapdom';
import { jxl } from '@zumer/snapdom-plugins/jxl';
const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [jxl()] });
const img = await result.toJxl({ quality: 0.8 });
const blob = await result.toBlob({ format: 'jxl' });
await result.download({ format: 'jxl', filename: 'card' });
Options
| Option | Type | Default | Description |
|---|---|---|---|
module | string | 'rapier-jxl/capture-complete' | With your codec: 'rapier-jxl/capture' (every pixel exact) or 'rapier-jxl/upload' (photographic) |
codec | object | none | Your own encoder with prepare and capture |
decoder | object | none | createCodec() from rapier-jxl/codec/decode, for toJxl() where JPEG XL does not show |
effort | number | 3 | Default effort, 1-9 |
webgpu | false | 'required' | none | Disable WebGPU, or require a device |
helpers | boolean | object | none | Helper workers for the encoder the plugin creates |
Exports take toWebp()'s options, plus effort, signal, onProgress (0 to 1) and onEncoded (once). quality: 1 is exact. The plugin's own encoder takes up to 40 megapixels; plugin.close() ends its workers.
Encoding works in every browser: toBlob() and download() give image/jxl. Where the browser cannot show JPEG XL (Edge, for one), toJxl() shows the decoder's pixels, or rejects with JXL_NOT_SHOWN without one.