# JXL Optim An ImageOptim-style drag-and-drop optimizer that re-encodes JPG / PNG / GIF into **JPEG XL** (`.jxl`). Native SwiftUI, macOS 12+. Wraps the `cjxl` encoder from [libjxl](https://github.com/libjxl/libjxl). ## Prerequisites ```sh brew install jpeg-xl # provides cjxl / djxl ``` The app looks for `cjxl` in `/usr/local/bin`, `/opt/homebrew/bin`, `/usr/bin`. If it isn't found you'll see a red banner with the install hint. ## Build & run ```sh swift run # dev: launches the window ./bundle.sh # builds "JXL Optim.app" (release, double-clickable) open "JXL Optim.app" ``` ## Use Drop images onto the window. Each is converted to a sibling `.jxl`; the row shows `before → after` and the percentage saved. A running total sits at the bottom. Controls: - **Lossless** — pixel-exact (`cjxl -d 0`). PNG/GIF stay perfect; JPEG is transcoded losslessly (decode-back gives the original). - **Quality** — visual distance `d0.5`–`d3.0` (lower = better). `d1` ≈ visually lossless. - **Effort** — encoder effort 1–9; higher is slower but smaller. - **Keep original** — off deletes the source after a successful encode. ## How it maps to cjxl `cjxl in.png out.jxl -e --num_threads 0 [-d 0 | -d ]` 讲解文章在 Niamos vault: `wiki/projects/自己写一个 JPEG XL 压缩器.md`。