jpegxl 8.4.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +294 -229
- package/dist/animation.browser.mjs +2 -2
- package/dist/animation.mjs +2 -2
- package/dist/capture-complete.browser.mjs +2 -2
- package/dist/capture-complete.mjs +2 -2
- package/dist/capture-groups.mjs +2 -2
- package/dist/capture.browser.mjs +2 -2
- package/dist/capture.mjs +2 -2
- package/dist/cli-add.mjs +2 -2
- package/dist/cli-astro.mjs +2 -2
- package/dist/cli-cloudflare.mjs +2 -2
- package/dist/cli-emdash.mjs +2 -2
- package/dist/cli-places.mjs +2 -2
- package/dist/cli-selftest.mjs +2 -2
- package/dist/cli-workers.mjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/decode.browser.mjs +2 -2
- package/dist/decode.mjs +2 -2
- package/dist/decode.node.mjs +2 -2
- package/dist/format.browser.mjs +2 -2
- package/dist/format.mjs +2 -2
- package/dist/hdr.mjs +2 -2
- package/dist/helpers.mjs +2 -2
- package/dist/index.browser.mjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/jpeg.browser.mjs +2 -2
- package/dist/jpeg.mjs +2 -2
- package/dist/jpeg.node.mjs +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/polyfill.mjs +2 -2
- package/dist/resumable.mjs +2 -2
- package/dist/resumable.node.mjs +2 -2
- package/dist/serve.mjs +2 -2
- package/dist/serve.node.mjs +2 -2
- package/dist/upload.browser.mjs +2 -2
- package/dist/upload.mjs +2 -2
- package/dist/verify.mjs +2 -2
- package/dist/verify.node.mjs +2 -2
- package/dist/wasm-modules.mjs +2 -2
- package/examples/agents/jxl-tools.mjs +8 -8
- package/examples/android/prepare-assets.mjs +2 -2
- package/examples/capacitor/prepare-assets.mjs +2 -2
- package/examples/emdash/admin-work.mjs +1 -1
- package/examples/emdash/backfill.mjs +4 -4
- package/examples/emdash/background.mjs +5 -5
- package/examples/emdash/browser-candidate.mjs +1 -1
- package/examples/emdash/deliver.mjs +2 -2
- package/examples/emdash/host-policy.mjs +6 -6
- package/examples/emdash/index.mjs +3 -3
- package/examples/emdash/job-runner.mjs +31 -31
- package/examples/emdash/job-store.mjs +21 -21
- package/examples/emdash/jpeg-source.mjs +2 -2
- package/examples/emdash/library-jobs.mjs +21 -21
- package/examples/emdash/local-store.mjs +16 -16
- package/examples/emdash/media-admin.mjs +9 -9
- package/examples/emdash/media-plugin.mjs +62 -62
- package/examples/emdash/media-storage.mjs +55 -55
- package/examples/emdash/media-words.mjs +89 -89
- package/examples/emdash/media-worker.mjs +1 -1
- package/examples/emdash/original-envelope.mjs +2 -2
- package/examples/emdash/originals.mjs +77 -77
- package/examples/emdash/r2-store.mjs +3 -3
- package/examples/emdash/read-all.mjs +14 -14
- package/examples/emdash/server-only.mjs +1 -1
- package/examples/emdash/storage.mjs +1 -1
- package/examples/emdash/structural-delivery.mjs +42 -42
- package/examples/emdash/thread-driver.mjs +15 -15
- package/examples/emdash/thread-worker.mjs +3 -3
- package/examples/emdash/work-queue.mjs +11 -11
- package/examples/flutter/prepare-assets.mjs +3 -3
- package/examples/ios/prepare-assets.mjs +3 -3
- package/examples/page-rects.js +14 -14
- package/examples/react-native/src/JXLProvider.tsx +19 -9
- package/examples/snapdom/jxl.js +3 -2
- package/examples/svg-jxl.js +10 -10
- package/package.json +1 -1
- package/types/animation.d.mts +2 -2
- package/types/capture-complete.d.mts +5 -5
- package/types/capture.d.mts +1 -1
- package/types/format.d.mts +2 -2
- package/types/index.d.mts +6 -6
- package/types/jpeg.d.mts +1 -1
- package/types/result.d.mts +5 -4
- package/types/resumable.d.mts +7 -7
- package/types/serve.d.mts +1 -1
- package/types/types.d.mts +19 -18
- package/types/upload.d.mts +1 -1
- package/types/verify.d.mts +4 -4
package/README.md
CHANGED
|
@@ -5,241 +5,221 @@
|
|
|
5
5
|
[](https://github.com/jackskip22/rapier-jxl/blob/main/LICENSE)
|
|
6
6
|
[](https://www.npmjs.com/package/jpegxl)
|
|
7
7
|
|
|
8
|
-
JPEG XL in
|
|
8
|
+
JPEG XL in WebAssembly + JS with optional WebGPU & parallel workers. Brotli: ~60 KB exact capture, ~290 KB complete capture, ~330 KB upload, ~485 KB full encoder. HDR, metadata, lossless JPEG, video/GIF to animation, resumable edge encoding, serve, polyfill, decode. Auto quality, exact text. CLI & npx jpegxl add: 16 platforms. No dependencies. MIT.
|
|
9
9
|
|
|
10
|
-
rapier-jxl,
|
|
10
|
+
rapier-jxl is the encoder inside [rapier.website](https://rapier.website), the free Markdown editor, drawing and painting app. Rapier is also a free [Android app](https://play.google.com/store/apps/details?id=app.rapier&referrer=utm_source%3Djxl-readme) that opens and converts JPEG XL pictures.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
rapier-jxl is the encoder inside [rapier.website](https://rapier.website), the free Markdown editor and painting app. Rapier is also a free [Android app](https://play.google.com/store/apps/details?id=app.rapier&referrer=utm_source%3Djxl-readme) that opens and converts JPEG XL pictures.
|
|
15
|
-
|
|
16
|
-
- Uploads over 2x faster than libvips.
|
|
17
|
-
- 61 KB Brotli exact capture.
|
|
18
|
-
- 293 KB Brotli complete capture.
|
|
19
|
-
- 331 KB Brotli upload.
|
|
20
|
-
- 485 KB Brotli full encoder with HDR and parallel workers. Used by [rapier.html](https://rapier.website)
|
|
21
|
-
- Lossless JPEG transcoding, decoding, verification, serving, metadata, animation, polyfill, CLI and resumable encoding
|
|
22
|
-
for edge isolates. Modules are single files.
|
|
23
|
-
- Browsers, workers, Node, Deno, Bun, Cloudflare Workers.
|
|
24
|
-
- No dependencies.
|
|
25
|
-
- MIT.
|
|
12
|
+
It is also used by [SnapDOM's official JPEG XL plugin](https://snapdom.dev/plugins/jxl/) and the [EmDash JPEG XL Image Optimizer plugin](https://plugins.emdashcms.com/plugins/@rapier.website/jxl). [Try rapier-jxl in your browser](https://rapier.website/jxl).
|
|
26
13
|
|
|
27
14
|
```sh
|
|
28
15
|
npm install jpegxl
|
|
29
16
|
```
|
|
30
17
|
|
|
31
|
-
ESM. From CommonJS: `await import('jpegxl')`.
|
|
18
|
+
ESM, Node 20.16+ or 22.3+. From CommonJS: `await import('jpegxl')`.
|
|
32
19
|
|
|
33
20
|
## Command line
|
|
34
21
|
|
|
35
22
|
```sh
|
|
36
|
-
npx jpegxl photo.png
|
|
37
|
-
npx jpegxl scan.jpg
|
|
38
|
-
npx jpegxl photos/ --out dist/
|
|
39
|
-
npx jpegxl hero.png --max-bytes 100KB
|
|
40
|
-
npx jpegxl scan.jxl --out back/
|
|
41
|
-
npx jpegxl photos/ --out dist/ --json # one JSON line per file, then a summary
|
|
23
|
+
npx jpegxl photo.png # photo.jxl alongside
|
|
24
|
+
npx jpegxl scan.jpg # lossless: JPEG restores exactly
|
|
25
|
+
npx jpegxl photos/ --out dist/ # every PNG, JPEG, WebP, AVIF, GIF, HDR and EXR in the folder
|
|
26
|
+
npx jpegxl hero.png --max-bytes 100KB # best quality that fits
|
|
27
|
+
npx jpegxl scan.jxl --out back/ # back/scan.jpg, original JPEG
|
|
42
28
|
```
|
|
43
29
|
|
|
44
|
-
`--quality 1–100
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
Options: `--quality 1–100` (default 90; a JPEG stays exact), `--effort 1–9` (default 7), `--max-bytes`, `--out`, `--exact`, `--jpeg-pixels`, `--jobs`, `--verify`, `--json`. A different file is never replaced.
|
|
31
|
+
|
|
32
|
+
## Add it to your project
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npx jpegxl add <place>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Places: `emdash`, `astro`, `vite`, `webpack`, `next`, `netlify`, `workers`, `r2`, `agents`, `android`, `ios`, `flutter`, `expo`, `capacitor`, `electron`, `tauri`. It works from the installed package (EmDash and Astro install what they lack), `--dry-run` shows what it would change, and `npx jpegxl remove <place>` undoes exactly what it wrote.
|
|
39
|
+
|
|
40
|
+
## No code required
|
|
41
|
+
|
|
42
|
+
- [rapier.website/jxl](https://rapier.website/jxl) converts pictures in the browser, offline, on your device.
|
|
43
|
+
- [JPEG XL Converter for VS Code](https://marketplace.visualstudio.com/items?itemName=rapier.jxl) converts files in a workspace.
|
|
44
|
+
- [Rapier for Android](https://play.google.com/store/apps/details?id=app.rapier&referrer=utm_source%3Djxl-readme) opens, converts and shares JPEG XL images.
|
|
50
45
|
|
|
51
46
|
## Upload
|
|
52
47
|
|
|
53
|
-
```
|
|
48
|
+
```ts
|
|
54
49
|
import {encode, fit} from 'jpegxl/upload';
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
const compress = async file => {
|
|
51
|
+
async function compress(file: File): Promise<Blob> {
|
|
58
52
|
const result = await encode(file, {fidelity: {quality: 82}});
|
|
59
|
-
if (!result.
|
|
53
|
+
if (!result.meetsTarget) throw new Error(result.reason.message);
|
|
60
54
|
return new Blob([result.bytes], {type: 'image/jxl'});
|
|
61
|
-
}
|
|
62
|
-
const small = file => fit(file, {maxBytes: 100_000}); //
|
|
55
|
+
}
|
|
56
|
+
const small = (file: File) => fit(file, {maxBytes: 100_000}); // `meetsTarget` says whether it fit
|
|
63
57
|
```
|
|
64
58
|
|
|
65
|
-
`variants` makes
|
|
66
|
-
cancelling. On Node and Deno, pass pixels `{data, width, height}`, or a PNG file as `new Blob([bytes])`. A JPEG needs one
|
|
67
|
-
setup step first. In Node, Deno or Bun, import `configureDecoder` from `jpegxl`, `decode` from `jpegxl/decode` and
|
|
68
|
-
`recompress` from `jpegxl/jpeg`, then call `configureDecoder(decode, null, recompress)` once.
|
|
69
|
-
A page with no bundler needs an import map or a path: `import {encode} from '../dist/upload.mjs'`.
|
|
59
|
+
Efforts 1 to 3 (default 3). `variants` makes multiple sizes from one picture. Every encoding call takes `onProgress` and `signal`. On Node, Deno and Bun a JPEG needs `configureDecoder(decode, null, recompress)` first. Pixels and PNG work normally.
|
|
70
60
|
|
|
71
61
|
## Encode
|
|
72
62
|
|
|
73
|
-
```
|
|
63
|
+
```ts
|
|
74
64
|
import {writeFile} from 'node:fs/promises';
|
|
75
65
|
import {encode} from 'jpegxl';
|
|
76
66
|
|
|
77
67
|
const picture = {data: new Uint8Array([240, 120, 40, 255]), width: 1, height: 1};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- `
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
- `
|
|
89
|
-
-
|
|
90
|
-
- `fidelity
|
|
91
|
-
- `
|
|
92
|
-
- Efforts 6–9 measure quality. Efforts 1–5 estimate it.
|
|
93
|
-
- `webgpu`: left out, efforts 7–9 use WebGPU where it helps; the result's `usedWebGPU` says whether it did. `'required'`
|
|
94
|
-
fails without it, and at efforts 1–6 or exact, which run on WebAssembly; `false` turns it off.
|
|
95
|
-
- `maxPixels`: no default bound; set it to bound memory. A side is at most 2^30 (the JPEG XL size field); what the host cannot hold refuses `JXL_MEMORY`. Very large images can be passed in strips with `rows(y, count)`.
|
|
96
|
-
- `verify(original, result)` from `jpegxl/verify` checks a file against its source: the file the encoder wrote. A file edited afterwards, such as one given Exif or XMP, is another file and is refused.
|
|
68
|
+
const {bytes} = await encode(picture, {fidelity: {quality: 90}});
|
|
69
|
+
if (bytes) await writeFile('picture.jxl', bytes);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Takes RGBA `{data, width, height}`, `ImageData`, a canvas, an `ImageBitmap`, a `VideoFrame`, a `Blob` or a GPU texture, in 8 or 16 bits, `Float16Array` or `Float32Array` (HDR).
|
|
73
|
+
|
|
74
|
+
- `fidelity`: `{quality: 1–100}`, default 90, or `'exact'`.
|
|
75
|
+
- `effort`: 1–9, default 7. Efforts 6–9 measure the look; 1–5 predict it.
|
|
76
|
+
- `webgpu`: efforts 7–9 use WebGPU where it can. `'required'` refuses without it. `false` turns it off.
|
|
77
|
+
- `progressive: true`: the first bytes show the whole picture, which sharpens as the rest arrives (about 2 to 5% more bytes).
|
|
78
|
+
- `onPreview` receives each better file while efforts 6–9 search, to show the picture forming.
|
|
79
|
+
- The host's memory is the limit.
|
|
80
|
+
- A JPEG stays JPEG and restores exactly with `fidelity: 'exact'` or at a quality level when that can be smaller (efforts 6–9). `jpeg: 'pixels'` encodes its pixels.
|
|
81
|
+
- `jpegxl/animation` takes frames or an animated GIF, `jpegxl/hdr` reads OpenEXR and Radiance files, `jpegxl/verify` checks a file against its source.
|
|
97
82
|
|
|
98
83
|
## Screenshots
|
|
99
84
|
|
|
100
|
-
```
|
|
85
|
+
```ts
|
|
101
86
|
import {capture} from 'jpegxl/capture';
|
|
102
|
-
import {capture as
|
|
87
|
+
import {capture as capturePage} from 'jpegxl/capture-complete';
|
|
88
|
+
import {pageRects} from 'jpegxl/page-rects';
|
|
103
89
|
|
|
104
|
-
const
|
|
105
|
-
|
|
90
|
+
const lossless = (canvas: HTMLCanvasElement) => capture(canvas);
|
|
91
|
+
// Lossy photos, exact text. `element` is what a library drew to the canvas.
|
|
92
|
+
const screenshot = (element: HTMLElement, canvas: HTMLCanvasElement) =>
|
|
93
|
+
capturePage(canvas, {...pageRects(element, canvas), fidelity: {quality: 92}});
|
|
106
94
|
```
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
- `rects` is `{exactRects, photoRects}`: the areas to keep lossless, such as text, and where the photos are.
|
|
110
|
-
- `jpegxl/page-rects` finds both in a page element, for any library that draws one to a canvas: `const rects = pageRects(element, canvas, {area}); await capture(canvas, {...rects, fidelity: {quality: 85}})`.
|
|
111
|
-
- Tall pages in one file, as tall as the browser draws them; WebP stops at 16,383.
|
|
112
|
-
- Efforts 6–9 check photo quality with the browser's JPEG XL decoder. In Node, Deno, Bun and desktop apps, the one setup
|
|
113
|
-
step is `configureDecoder(decode)`, with `decode` from `jpegxl/decode`.
|
|
96
|
+
`pageRects` finds the text and photos in an element; `exactRects` and `photoRects` take the boxes by hand. Text is exact at every effort.
|
|
114
97
|
|
|
115
|
-
|
|
116
|
-
|---|---|
|
|
117
|
-
| 1–3 | Fast. 3 is the default, 2 for quick saves, 1 for live previews. |
|
|
118
|
-
| 4–5 | Deeper search: smaller text, graphics and photos without quality loss. |
|
|
119
|
-
| 6–9 | Automatically finds the smallest file at the quality you choose. 7–9 also search block sizes. |
|
|
98
|
+
## SnapDOM
|
|
120
99
|
|
|
121
|
-
|
|
100
|
+
```js
|
|
101
|
+
import {snapdom} from '@zumer/snapdom';
|
|
102
|
+
import {jxl} from '@zumer/snapdom-plugins/jxl';
|
|
103
|
+
|
|
104
|
+
const result = await snapdom(document.querySelector('#card'), {plugins: [jxl()]});
|
|
105
|
+
await result.download({format: 'jxl', filename: 'card'});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
[SnapDOM's official JPEG XL plugin](https://snapdom.dev/plugins/jxl/) captures any element as one file. It compresses images inside screenshots while automatically keeping text exact.
|
|
109
|
+
|
|
110
|
+
## Animation
|
|
122
111
|
|
|
123
112
|
```js
|
|
113
|
+
import {encode} from 'jpegxl/animation';
|
|
114
|
+
|
|
115
|
+
const gif = await (await fetch('cat.gif')).blob();
|
|
116
|
+
const {bytes} = await encode(gif);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Upload a video or GIF to make it a much smaller animated JPEG XL without losing its quality. It keeps every frame's timing and the loop count. Frames can also be pixels: `{width, height, loops, frames: [{data, duration}]}`.
|
|
120
|
+
|
|
121
|
+
## JPEG, decoding, metadata
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
124
|
import {recompress, restore} from 'jpegxl/jpeg';
|
|
125
125
|
import {decode} from 'jpegxl/decode';
|
|
126
126
|
import {header} from 'jpegxl/metadata';
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
async function roundTrip(jpeg: Uint8Array) {
|
|
129
|
+
const packed = await recompress(jpeg);
|
|
130
|
+
if (!packed.meetsTarget) throw new Error(packed.reason.message);
|
|
131
|
+
return (await restore(packed.bytes)).bytes; // the original JPEG
|
|
132
|
+
}
|
|
133
|
+
const pixels = async (file: Uint8Array) => (await decode(file)).data; // RGBA
|
|
134
|
+
const size = (file: Uint8Array) => header(file); // synchronous
|
|
133
135
|
```
|
|
134
136
|
|
|
135
|
-
`
|
|
136
|
-
`recompress` runs at effort 7 unless given one. `restore(...)` returns `{bytes, ...}`; the JPEG is `.bytes`.
|
|
137
|
-
When a JPEG's trailing data (such as a phone's motion-photo video) is longer than the format's reconstruction box holds, recompress's and verify's records carry `otherDecoders: {missing, reason: 'past-jbrd'}`: other decoders return the JPEG without its last `missing` bytes, while `restore` returns all of it.
|
|
137
|
+
`recompress(jpeg, {gainMap: true})` keeps a phone photo's HDR gain map and still restores the JPEG exactly. `slice` and `placeholder` from `jpegxl/metadata` cut a smaller size (1:2, 1:4 or 1:8) from a progressive file in milliseconds, without decoding.
|
|
138
138
|
|
|
139
|
-
`jpegxl/svg-jxl` converts the
|
|
140
|
-
`{fidelity: 'exact'}` keeps the images lossless.
|
|
139
|
+
`jpegxl/svg-jxl` converts the pictures inside an SVG and keeps shapes and text sharp.
|
|
141
140
|
|
|
142
141
|
## Serving
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
`Vary: Accept`, ETag, `304` and `HEAD`.
|
|
146
|
-
|
|
147
|
-
```js
|
|
143
|
+
```ts
|
|
148
144
|
import {createServer} from 'node:http';
|
|
149
145
|
import {readFile} from 'node:fs/promises';
|
|
150
146
|
import {serve} from 'jpegxl/serve';
|
|
151
147
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
createServer((req, res) => serve(stored, req, res)).listen(3000);
|
|
148
|
+
const stored = await readFile('photo.jxl'); // made once: npx jpegxl photo.jpg
|
|
149
|
+
createServer((req, res) => void serve(stored, req, res)).listen(3000);
|
|
155
150
|
```
|
|
156
151
|
|
|
157
|
-
|
|
158
|
-
`private, no-cache`).
|
|
152
|
+
JPEG XL to browsers that accept it, the original JPEG to the rest, with `Vary: Accept`, ETag, `304` and `HEAD`. Workers, Deno and Bun: `return serve(stored, request)`.
|
|
159
153
|
|
|
160
|
-
|
|
154
|
+
`width`, `maxBytes` or `responsive: true` send smaller screens a smaller size cut from the same progressive file.
|
|
161
155
|
|
|
162
|
-
|
|
163
|
-
as one call.
|
|
156
|
+
## Workers and queues
|
|
164
157
|
|
|
165
|
-
```
|
|
166
|
-
import {
|
|
167
|
-
import {encode} from 'jpegxl/upload';
|
|
168
|
-
import {verify} from 'jpegxl/verify';
|
|
169
|
-
|
|
170
|
-
// store: the original and the job's parts (R2, KV, a database). input names the original:
|
|
171
|
-
// {generation, sha256, byteLength}, with kind: 'file' for an uploaded file.
|
|
172
|
-
const step = async (saved, store, input, memoryBytes) => {
|
|
173
|
-
const job = {operation: encode, store, input, verify, memoryBytes};
|
|
174
|
-
const {checkpoint, done} = await advance(saved ?? await start({...job, options: {fidelity: {quality: 82}}}), job);
|
|
175
|
-
return done ? {result: await finish(checkpoint, job)} : {checkpoint}; // save checkpoint for the next request
|
|
176
|
-
};
|
|
177
|
-
```
|
|
158
|
+
```ts
|
|
159
|
+
import {encode, configure, close} from 'jpegxl/upload';
|
|
178
160
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
`jpegxl/jpeg` in each new isolate. The resumable module carries no decoder.
|
|
188
|
-
- Keep the original immutable for its `generation` and SHA-256. Save the returned checkpoint with a revision check
|
|
189
|
-
after its parts are durable, and accept checkpoints only from your service. `finish` assembles the saved output;
|
|
190
|
-
hashing, decoding and scoring have already finished in the advances.
|
|
191
|
-
- `workerAdmission({operation, options, width, height})` says whether a job fits a Cloudflare Workers isolate (128 MB), from measured memory per operation, effort and size. A size not measured is not admitted; convert it in the browser.
|
|
192
|
-
- `workerAdmission` answers for `rapier-jxl`, `jpegxl/upload` (efforts 1-3, default 3) and `jpegxl/jpeg`.
|
|
193
|
-
- `store` is `{readSource(offset, length), read(ref), write(ref, bytes)}`. `input` is `{generation, sha256, byteLength, kind: 'file'}`; `sha256` is 64 lowercase hex digits, without a `sha256:` prefix.
|
|
194
|
-
|
|
195
|
-
For a candidate uploaded separately, use the existing `verify` verb. Store the candidate as immutable, ordered parts
|
|
196
|
-
of at most 1 MiB, each named by its SHA-256. Pass its result metadata without `bytes` or a `verification` receipt:
|
|
161
|
+
configure({helpers: {count: 3, memoryBytes: 1 << 30}});
|
|
162
|
+
try {
|
|
163
|
+
const photo = {data: new Uint8Array(1200 * 900 * 4).fill(200), width: 1200, height: 900};
|
|
164
|
+
const {bytes} = await encode(photo);
|
|
165
|
+
} finally {
|
|
166
|
+
await close();
|
|
167
|
+
}
|
|
168
|
+
```
|
|
197
169
|
|
|
198
|
-
|
|
199
|
-
import {start, finish} from 'jpegxl/resumable';
|
|
200
|
-
import {verify} from 'jpegxl/verify';
|
|
170
|
+
In browsers the module runs in its own worker. Node, Deno and Bun run it in the calling thread alongside `helpers`. `configure` sets a module's queue before its first call and `close()` ends its worker. Canceled calls reject with the signal's reason.
|
|
201
171
|
|
|
202
|
-
|
|
203
|
-
const begin = (store, input, result, parts) => start({...job(store, input), options: {result, parts}});
|
|
204
|
-
// Persist and advance the checkpoint as above. When done, finish returns the receipt:
|
|
205
|
-
const done = (checkpoint, store, input) => finish(checkpoint, job(store, input));
|
|
206
|
-
```
|
|
172
|
+
## Resumable encoding
|
|
207
173
|
|
|
208
|
-
|
|
209
|
-
`error.verification`. The service verifies the original generation and candidate revision again before publication;
|
|
210
|
-
metadata supplied by the uploader is a claim to check.
|
|
174
|
+
For edge isolates with short time limits: an encode continues across requests in steps and writes the same file as one call.
|
|
211
175
|
|
|
212
|
-
|
|
176
|
+
```ts
|
|
177
|
+
import {start, advance, finish, type ResumableStore} from 'jpegxl/resumable';
|
|
178
|
+
import {encode} from 'jpegxl/upload';
|
|
213
179
|
|
|
214
|
-
|
|
180
|
+
// A Map and store. In production: R2, KV or a database.
|
|
181
|
+
const memoryStore = (original: Uint8Array): ResumableStore => {
|
|
182
|
+
const parts = new Map<string, Uint8Array>();
|
|
183
|
+
return {
|
|
184
|
+
readSource: (offset, length) => original.subarray(offset, offset + length),
|
|
185
|
+
read: ref => parts.get(ref.hash)!,
|
|
186
|
+
write: (ref, bytes) => void parts.set(ref.hash, bytes),
|
|
187
|
+
};
|
|
188
|
+
};
|
|
215
189
|
|
|
216
|
-
|
|
217
|
-
|
|
190
|
+
async function run(original: Uint8Array, sha256: string) {
|
|
191
|
+
const input = {generation: '1', sha256, byteLength: original.length, kind: 'file' as const};
|
|
192
|
+
const job = {operation: encode, store: memoryStore(original), input};
|
|
193
|
+
let state = await advance(await start({...job, options: {fidelity: {quality: 82}}}), job);
|
|
194
|
+
while (!state.done) state = await advance(state.checkpoint, job); // one request each: save the checkpoint
|
|
195
|
+
return finish(state.checkpoint, job);
|
|
196
|
+
}
|
|
218
197
|
```
|
|
219
198
|
|
|
220
|
-
|
|
199
|
+
`capture`, `encode`, `fit`, `variants`, `recompress`, `restore` and `verify` all resume. An advance runs about 30 ms (`budget: {ms}`) and at least one step, which can take longer. `workerAdmission({operation: encode, width, height})` says whether a job fits a Workers isolate. Accept checkpoints only from your own service.
|
|
221
200
|
|
|
222
|
-
|
|
201
|
+
## Browsers
|
|
223
202
|
|
|
224
|
-
```
|
|
225
|
-
|
|
203
|
+
```html
|
|
204
|
+
<script type="module">
|
|
205
|
+
import {encode} from 'https://cdn.jsdelivr.net/npm/jpegxl@8/dist/index.browser.mjs';
|
|
206
|
+
const canvas = document.querySelector('canvas');
|
|
207
|
+
if (canvas) await encode(canvas);
|
|
208
|
+
</script>
|
|
226
209
|
```
|
|
227
210
|
|
|
228
|
-
|
|
211
|
+
- The Content Security Policy needs `'wasm-unsafe-eval'`, and from a CDN `blob:` in `worker-src`.
|
|
212
|
+
- WebAssembly with SIMD is needed.
|
|
213
|
+
- Without native JPEG XL, `install()` from `jpegxl/polyfill` shows `.jxl` and `data:image/jxl` images, and `verify` needs `configureDecoder(decode, restore)` first.
|
|
214
|
+
- Each module's file is its own worker. With esbuild or Angular, copy it beside the bundle.
|
|
229
215
|
|
|
230
|
-
|
|
231
|
-
// astro.config.mjs
|
|
232
|
-
import emdash from 'emdash/astro';
|
|
233
|
-
import {jxl} from 'jpegxl/emdash';
|
|
216
|
+
## EmDash
|
|
234
217
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
218
|
+
```sh
|
|
219
|
+
npx jpegxl add emdash
|
|
238
220
|
```
|
|
239
221
|
|
|
240
|
-
Originals stay in the site's
|
|
241
|
-
get verified copies; other browsers get the original. Open **Plugins → JPEG XL Image Optimizer** to choose the goal, effort
|
|
242
|
-
and widths or convert the existing library. Without `jxl()`, the site serves its originals.
|
|
222
|
+
Originals stay in the site's storage. Browsers that accept JPEG XL get verified copies and the rest get the original. **Plugins → JPEG XL Image Optimizer** sets the goal, effort and widths, and converts the library. The package's `examples/emdash/astro.config.mjs` is a whole config.
|
|
243
223
|
|
|
244
224
|
## Astro
|
|
245
225
|
|
|
@@ -247,7 +227,7 @@ and widths or convert the existing library. Without `jxl()`, the site serves its
|
|
|
247
227
|
npx jpegxl add astro
|
|
248
228
|
```
|
|
249
229
|
|
|
250
|
-
Then `<
|
|
230
|
+
Then `<Picture src={photo} formats={['jxl', 'webp']} alt="" />`: a browser without JPEG XL takes the WebP. Astro 6 and 7. `jxl({jpeg: 'exact'})` keeps each JPEG restorable exactly.
|
|
251
231
|
|
|
252
232
|
- [Photos average 24% smaller than Astro's default WebP.](https://github.com/jackskip22/rapier-jxl/blob/main/bench/README.md#astro)
|
|
253
233
|
- [JPEGs 18% smaller, lossless.](https://github.com/jackskip22/rapier-jxl/blob/main/bench/README.md#astro)
|
|
@@ -263,6 +243,34 @@ Then `import hero from './hero.jpg?jxl'`. Vite 6, 7 and 8.
|
|
|
263
243
|
- [Photos 39% smaller than WebP and 11% smaller than AVIF at the same look.](https://github.com/jackskip22/rapier-jxl/blob/main/bench/README.md#vite)
|
|
264
244
|
- [Camera JPEGs 17% smaller, lossless.](https://github.com/jackskip22/rapier-jxl/blob/main/bench/README.md#vite)
|
|
265
245
|
|
|
246
|
+
## webpack
|
|
247
|
+
|
|
248
|
+
```sh
|
|
249
|
+
npx jpegxl add webpack
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Then `import hero from './hero.jpg?jxl'`. webpack 5 and Rspack.
|
|
253
|
+
|
|
254
|
+
## Next.js
|
|
255
|
+
|
|
256
|
+
```sh
|
|
257
|
+
npx jpegxl add next
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
`<Image>` serves JPEG XL to browsers that show it and Next's own image to the rest, with no component changes. After `next build`, each width next/image asks for is written once. Next.js 15 and 16.
|
|
261
|
+
|
|
262
|
+
- Photos 24% smaller than Next's default WebP at the same look.
|
|
263
|
+
|
|
264
|
+
## Netlify
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
npx jpegxl add netlify
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
After each build, every JPEG and PNG the site publishes gets a JPEG XL copy beside it, and browsers that show JPEG XL get that copy at the same address. Everyone else gets the original.
|
|
271
|
+
|
|
272
|
+
- JPEGs about a fifth smaller, lossless.
|
|
273
|
+
|
|
266
274
|
## Cloudflare Workers
|
|
267
275
|
|
|
268
276
|
```sh
|
|
@@ -270,17 +278,17 @@ npx jpegxl public/ --out public/
|
|
|
270
278
|
npx jpegxl add workers --route example.com/*
|
|
271
279
|
```
|
|
272
280
|
|
|
273
|
-
|
|
281
|
+
On Workers Free, the Worker serves the JPEG XL files to compatible browsers and the original to the rest. `--paid` also encodes missing ones in the Worker and keeps them in R2.
|
|
274
282
|
|
|
275
283
|
- [Phone JPEGs 18% smaller, lossless.](https://github.com/jackskip22/rapier-jxl/blob/main/bench/README.md#cloudflare-workers)
|
|
276
284
|
|
|
277
285
|
## Cloudflare R2
|
|
278
286
|
|
|
279
287
|
```sh
|
|
280
|
-
npx jpegxl add r2
|
|
288
|
+
npx jpegxl add r2 --bucket photos
|
|
281
289
|
```
|
|
282
290
|
|
|
283
|
-
Every JPEG
|
|
291
|
+
Every JPEG and PNG put in the bucket gets a JPEG XL beside it: a JPEG's restores the original exactly, a PNG's keeps every pixel. A picture too large for one Worker call runs as a Workflow, step by step from resumable checkpoints. Reads get the JPEG XL when the browser accepts it and the original otherwise.
|
|
284
292
|
|
|
285
293
|
## Cloudflare Agents
|
|
286
294
|
|
|
@@ -288,92 +296,149 @@ Every JPEG or PNG put into the bucket gets a JPEG XL file beside it, made from t
|
|
|
288
296
|
npx jpegxl add agents
|
|
289
297
|
```
|
|
290
298
|
|
|
291
|
-
|
|
299
|
+
In an Agents SDK project: an MCP server with five JPEG XL tools, `jxl_convert`, `jxl_recompress`, `jxl_restore`, `jxl_verify` and `jxl_inspect`, and the same tools for an Agent class. Pictures stay in R2 and the tools pass their keys, never the bytes, through the conversation.
|
|
292
300
|
|
|
293
|
-
##
|
|
301
|
+
## Android
|
|
302
|
+
|
|
303
|
+
```sh
|
|
304
|
+
npx jpegxl add android
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The same files run in an Android app with no native code. A hidden WebView runs the encoder in a worker, offline from the app's assets, and Kotlin passes files over a binary message port. Works for every processor with no NDK and no Internet permission. The encoder's files add about 1.2 MB to the APK.
|
|
294
308
|
|
|
295
309
|
```js
|
|
296
|
-
|
|
310
|
+
// assets/encoder.mjs, the WebView's worker
|
|
311
|
+
import {encode} from './jpegxl/upload.mjs';
|
|
312
|
+
import {recompress, restore} from './jpegxl/jpeg.mjs';
|
|
313
|
+
|
|
314
|
+
onmessage = async ({data: {bytes, mime, jpegBytes}}) => { // from Kotlin's message port
|
|
315
|
+
const photo = await encode(new Blob([bytes], {type: mime}), {fidelity: {quality: 80}});
|
|
316
|
+
const smaller = await recompress(jpegBytes);
|
|
317
|
+
const original = await restore(smaller.bytes); // the exact same JPEG
|
|
318
|
+
};
|
|
319
|
+
```
|
|
297
320
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
321
|
+
The [Android example](https://github.com/jackskip22/rapier-jxl/tree/main/examples/android) is one activity: pick or share a photo, save or share the `.jxl`, and recompress a JPEG with the restored file's SHA-256 checked in Kotlin. Android 8.0 or newer, WebView 116 or newer. The [Capacitor example](https://github.com/jackskip22/rapier-jxl/tree/main/examples/capacitor) uses the same modules unchanged.
|
|
322
|
+
|
|
323
|
+
## iOS and macOS
|
|
324
|
+
|
|
325
|
+
```sh
|
|
326
|
+
npx jpegxl add ios
|
|
305
327
|
```
|
|
306
328
|
|
|
307
|
-
|
|
308
|
-
needed. Imported inside a worker of your own, it runs there. Node, Deno, Bun and edge hosts run it in the calling thread.
|
|
309
|
-
- `configure` sets a module's queue before its first call: `helpers`, `maxPixels`, and in a browser `maxPendingBytes`,
|
|
310
|
-
`maxPendingJobs` and `workerFactory`. `close()` ends its worker and helpers; the next call starts them again.
|
|
311
|
-
- `helpers` adds worker threads; `helpers: true` sizes them by the device.
|
|
312
|
-
- `transfer: true` on encode, fit, variants or capture hands the pixels' buffer to the call instead of copying it; the buffer is empty afterwards.
|
|
313
|
-
- Errors carry a `code`, such as `JXL_INPUT`, `JXL_OPTIONS`, `JXL_WASM` or `JXL_WEBGPU`.
|
|
314
|
-
|
|
315
|
-
### Error codes
|
|
316
|
-
|
|
317
|
-
Every package refusal has a `code`. The message gives the specific cause; use this table for the next step. Caller-thrown errors and cancellation reasons pass through unchanged.
|
|
318
|
-
|
|
319
|
-
| Code | What happened | What to do |
|
|
320
|
-
| --- | --- | --- |
|
|
321
|
-
| `JXL_INPUT` | The image, bytes or source record cannot be read as supplied. | Pass a supported image or the pixel shape named in the message; replace a damaged source file. |
|
|
322
|
-
| `JXL_OPTIONS` | An option name or value is not accepted. | Use the option name, allowed value or range given in the message. |
|
|
323
|
-
| `JXL_DIMENSIONS` | Picture width, height or pixel count exceeds the allowed size. | Use positive whole-pixel dimensions and reduce the size, or raise `maxPixels` when appropriate. |
|
|
324
|
-
| `JXL_JPEG` | The JPEG file is missing required data or contains malformed markers. | Pass a complete, valid JPEG file. |
|
|
325
|
-
| `JXL_DECODE` | The JPEG XL file cannot be decoded correctly. | Check that the input is a complete JPEG XL file and use a suitable decoder. |
|
|
326
|
-
| `JXL_RECONSTRUCTION` | The JPEG XL file does not contain an original JPEG to restore. | Restore from a file made with `recompress()`, or decode the JPEG XL image instead. |
|
|
327
|
-
| `JXL_TARGET` | The requested file size, image-quality target or verification claim cannot be met. | Reduce the requirement or keep the original; consult the result's target details. |
|
|
328
|
-
| `JXL_PLATFORM` | This environment lacks a required image or decoding capability. | Follow the message's setup instructions or use an environment with that capability. |
|
|
329
|
-
| `JXL_MEMORY` | Available memory or a configured queue budget is insufficient. | Use a smaller image, reduce concurrent jobs or increase the relevant memory budget. |
|
|
330
|
-
| `JXL_LIMIT` | An input, output or operation exceeds a permitted byte or work limit. | Reduce the input or output, or increase the named limit where supported. |
|
|
331
|
-
| `JXL_WASM` | WebAssembly is blocked, lacks SIMD, or its module failed to compile or start (the host's words are in the message and `cause`). | Allow WebAssembly, use a host with SIMD, or act on the host's words. |
|
|
332
|
-
| `JXL_WEBGPU` | A required GPU is unavailable, or this job does not use WebGPU. | Leave `webgpu` unset, or choose a supported GPU and a compatible effort. |
|
|
333
|
-
| `JXL_WORKER` | A worker could not start, communicate or finish. | Allow the required worker source and check the worker setup described in the message. |
|
|
334
|
-
| `JXL_IO` | An input, output or stored file could not be accessed. | Check the path, permissions and storage access, then retry. |
|
|
335
|
-
| `JXL_CLOSED` | A worker queue is closing or already closed. | Finish closing it before starting further work; create a new queue where required. |
|
|
336
|
-
| `JXL_UNSUPPORTED` | This operation does not offer the requested input or feature combination. | Use the supported module, input or settings named in the message. |
|
|
337
|
-
| `JXL_SETUP` | An `add` or `remove` command cannot safely change project files. | Follow the manual setup step in the message, or repair the package installation. |
|
|
338
|
-
| `JXL_INTERNAL` | The library encountered a problem it could not handle. | Report the operation, input type and options with a reproducible example. |
|
|
329
|
+
The same files run on macOS or iOS with no native code. A Swift package runs the encoder in a hidden WKWebView offline, with cancellable async calls. Nothing to compile, no libjxl, no binary frameworks.
|
|
339
330
|
|
|
331
|
+
The [iOS example](https://github.com/jackskip22/rapier-jxl/tree/main/examples/ios) encodes photos, recompresses JPEGs losslessly and turns videos into animated JPEG XL.
|
|
340
332
|
|
|
341
|
-
|
|
333
|
+
```swift
|
|
334
|
+
import RapierJXL
|
|
342
335
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
336
|
+
let codec = JXLCodec()
|
|
337
|
+
let jxl = try await codec.encode(photo, quality: 80, effort: 3) // Data (or UIImage on iOS) in, JPEG XL out
|
|
338
|
+
let small = try await codec.recompress(jpeg: jpegData) // the same JPEG back with restore
|
|
339
|
+
let clip = try await codec.animate(video: movieURL) // every frame, each with its time
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Flutter
|
|
343
|
+
|
|
344
|
+
```sh
|
|
345
|
+
npx jpegxl add flutter
|
|
348
346
|
```
|
|
349
347
|
|
|
350
|
-
|
|
348
|
+
A Dart package runs the encoder in a hidden web view, offline, with no native codec. Android 8.0, iOS 16.4 and macOS 13.3 or newer.
|
|
349
|
+
|
|
350
|
+
```dart
|
|
351
|
+
import 'package:rapier_jxl/rapier_jxl.dart';
|
|
351
352
|
|
|
352
|
-
|
|
353
|
+
final codec = JXLCodec();
|
|
354
|
+
final jxl = await codec.encode(photoBytes, quality: 80, effort: 3);
|
|
355
|
+
final clip = await codec.animateVideo(mp4Bytes, type: 'video/mp4');
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## React Native and Expo
|
|
359
|
+
|
|
360
|
+
```sh
|
|
361
|
+
npx jpegxl add expo
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
A hidden WebView runs the encoder, so Expo managed apps and Expo Go work unchanged. Nothing leaves the device.
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
const App = () => <JXLProvider><Screen /></JXLProvider>;
|
|
368
|
+
const jxl = useJXL(); // in Screen
|
|
369
|
+
const out = await jxl.encode(photo, {quality: 80, effort: 3});
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Capacitor
|
|
373
|
+
|
|
374
|
+
```sh
|
|
375
|
+
npx jpegxl add capacitor
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
The encoder runs in web workers inside the app. Capacitor's Filesystem plug-in saves the file; there is no codec bridge.
|
|
379
|
+
|
|
380
|
+
## Electron
|
|
381
|
+
|
|
382
|
+
```sh
|
|
383
|
+
npx jpegxl add electron
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
The browser files run in Electron's window as they are: no native codec and no rebuild. The Node files run in the main process too.
|
|
387
|
+
|
|
388
|
+
## Tauri
|
|
389
|
+
|
|
390
|
+
```sh
|
|
391
|
+
npx jpegxl add tauri
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
The browser files run in Tauri 2's web view: WebView2 on Windows, WebKit on macOS, WebKitGTK on Linux. No Rust codec crate; the Rust side stays yours.
|
|
395
|
+
|
|
396
|
+
Native code is faster. rapier-jxl doesn't need any and brings everything above to the phone: quality measured visually, text kept exact in screenshots and the same files as on the web.
|
|
397
|
+
|
|
398
|
+
## Errors
|
|
399
|
+
|
|
400
|
+
Every refusal carries a `code`:
|
|
401
|
+
|
|
402
|
+
| Code | Meaning |
|
|
353
403
|
| --- | --- |
|
|
354
|
-
|
|
|
355
|
-
|
|
|
356
|
-
|
|
|
357
|
-
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
404
|
+
| `JXL_OPTIONS` | An option is unknown or not allowed. |
|
|
405
|
+
| `JXL_INPUT` | The input is missing, empty, wrong for the call, or changed while read. |
|
|
406
|
+
| `JXL_DIMENSIONS` | The picture is larger than the format or the host allows. |
|
|
407
|
+
| `JXL_JPEG`, `JXL_DECODE` | Not a JPEG, or not a valid JPEG XL file. |
|
|
408
|
+
| `JXL_RECONSTRUCTION` | No JPEG reconstruction data in the file. |
|
|
409
|
+
| `JXL_TARGET` | The fidelity asked for cannot be reached. |
|
|
410
|
+
| `JXL_PLATFORM` | This host cannot decode the input or lacks an API. |
|
|
411
|
+
| `JXL_MEMORY`, `JXL_LIMIT` | Not enough memory, or a byte or queue bound you set. |
|
|
412
|
+
| `JXL_WASM`, `JXL_WEBGPU` | No WebAssembly with SIMD, or `webgpu: 'required'` with no device. |
|
|
413
|
+
| `JXL_WORKER`, `JXL_IO` | A worker would not start, or a Blob or image could not be read. |
|
|
414
|
+
| `JXL_CLOSED` | The codec is closed. |
|
|
415
|
+
| `JXL_SETUP` | `npx jpegxl add` does not recognize the folder; nothing was changed. |
|
|
416
|
+
| `JXL_UNSUPPORTED` | A valid request this version does not do. |
|
|
417
|
+
| `JXL_INTERNAL` | A fault in rapier-jxl. |
|
|
418
|
+
|
|
419
|
+
## Modules
|
|
420
|
+
|
|
421
|
+
Brotli 11 size of each module's file: `jpegxl` about 485 KB, `upload` 330, `capture` 60, `capture-complete` 290, `animation` 505, `format` 525 (codestream features), `jpeg` 170, `decode` 115, `verify` 85, `serve` 75, `resumable` 70, `metadata` 40, `polyfill` 23, `hdr` 13.
|
|
369
422
|
|
|
370
423
|
## License
|
|
371
424
|
|
|
372
425
|
MIT. Third-party notices: `THIRD_PARTY_NOTICES`.
|
|
373
426
|
|
|
427
|
+
## Agents
|
|
428
|
+
|
|
429
|
+
```sh
|
|
430
|
+
npx jpegxl photos/ --out out/ --json
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
The package contains an agent skill, `skills/rapier-jxl/SKILL.md` with files and folders, byte budgets and JPEGs restored exactly. With `--json` there is one JSON object per file and a summary, and nothing else on stdout. `npx jpegxl add <place>` sets up any of the 16 places above. In a chat, [Rapier's MCP server](https://rapier.website/agents) converts pictures to JPEG XL.
|
|
434
|
+
|
|
435
|
+
## Help by testing on your phone
|
|
436
|
+
|
|
437
|
+
It is very complicated to optimize encoder speed for every phone's GPU and rapier-jxl is meant to be great on every device. Open [rapier.website/docs/jxl-job.html](https://rapier.website/docs/jxl-job.html) on your phone and tap **Start**. It encodes a photo and a camera picture with and without WebGPU, checks that every file is the same, and logs the times automatically when it's done. All you have to do is leave the browser open for about 10 minutes on your iPhone or Android phone.
|
|
438
|
+
|
|
374
439
|
## Contributing
|
|
375
440
|
|
|
376
|
-
Anybody is welcome to contribute to rapier-jxl, which is intended to be as universal as possible. You can also greatly assist the project by simply performing tests on your computer which is always turning up new edge cases to improve the encoder. Testing on every kind of device is essential for a universal encoder. Check the jobs/ folder in the repo root, open an issue with the job's name as its title if you've started work on it, then please submit your results by attaching them to that issue.
|
|
441
|
+
Anybody is welcome to contribute to rapier-jxl, which is intended to be as universal as possible. You can also greatly assist the project by simply performing tests on your computer or phone which is always turning up new edge cases to improve the encoder. Testing on every kind of device is essential for a universal encoder. Check the jobs/ folder in the repo root, open an issue with the job's name as its title if you've started work on it, then please submit your results by attaching them to that issue.
|
|
377
442
|
|
|
378
443
|
For feedback, requests or questions, feel free to join the discussion. The goal is to make rapier-jxl as easy, fast, small, powerful and reliable as possible for every use case, while keeping the architecture simple and general.
|
|
379
444
|
|