# 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 ]` ## 分发与公证 `./bundle.sh` 默认 ad-hoc 签名,本机可直接打开。对外分发需 Apple Developer ID: ```sh SIGN_ID="Developer ID Application: NAME (TEAMID)" ./bundle.sh ditto -c -k --keepParent "JXL Optim.app" JXLOptim.zip xcrun notarytool submit JXLOptim.zip --apple-id you@me.com --team-id TEAMID --wait xcrun stapler staple "JXL Optim.app" ``` ## 多格式编码器 | 输出 | CLI | 安装 | |---|---|---| | JPEG XL | cjxl | `brew install jpeg-xl` | | AVIF | avifenc | `brew install libavif` | | WebP | cwebp | `brew install webp` | 讲解文章在 Niamos vault: `wiki/projects/自己写一个 JPEG XL 压缩器.md`。