jxl-encoder
Pure Rust JPEG XL encoder. Lossy (VarDCT) and lossless (Modular) encoding, verified against three independent decoders (jxl-rs, jxl-oxide, djxl). #![forbid(unsafe_code)].
740+ tests passing.
Quick start
use ;
// Lossy — distance 1.0 is visually lossless
let jxl = new
.encode?;
// Lossless
let jxl = new
.encode?;
// Full control — limits, metadata, cancellation
use Limits;
let jxl = new
.with_ans
.with_gaborish
.encode_request
.with_limits
.encode?;
Pixel layouts
Rgb8, Rgba8, Bgr8, Bgra8, Gray8, GrayAlpha8, Rgb16, Rgba16, Gray16, RgbLinearF32.
Lossy encoding supports all layouts including alpha (VarDCT for RGB + modular for the alpha channel). Lossless supports RGB, RGBA, grayscale, and gray+alpha.
What works
Lossy (VarDCT): 19/27 AC strategies (all that libjxl evaluates through effort 7), ANS entropy coding, adaptive quantization, chroma-from-luma, gaborish, pixel-domain loss, butteraugli quantization loop, custom coefficient ordering, noise synthesis, error diffusion, EPF sharpness, JPEG re-encoding.
Lossless (Modular): RCT (all 42 variants), ANS + Huffman, LZ77 (RLE + hash chain), histogram clustering, content-adaptive MA tree learning, palette transform, squeeze (Haar wavelet), 14/14 predictors including Weighted.
Animation: Both lossy and lossless, per-frame duration, loop count, frame crop detection.
Input formats: 8-bit sRGB, 16-bit sRGB, linear f32, grayscale, alpha. BGR/BGRA layouts.
Lossy quality vs libjxl: Within 3% of cjxl effort 5 at low distances (d <= 1.0). The gap widens to ~22-26% at higher distances due to missing cost model refinements (iterative rate control, full histogram clustering).
Features
| Feature | Default | Description |
|---|---|---|
std |
yes | Standard library support; enables encode_to() for Write targets |
butteraugli-loop |
yes | Iterative quant field refinement via butteraugli distmap |
safe-mode |
yes | Guard flag (no behavioral effect; multi-group works correctly) |
rate-control |
no | Iterative encode for precise distance targeting |
jpeg-reencoding |
no | JPEG bitstream re-encoding into JXL |
trace-bitstream |
no | Zero-cost bitstream tracing for debugging |
License
Dual-licensed: AGPL-3.0 or commercial.
I've maintained and developed open-source image server software — and the 40+ library ecosystem it depends on — full-time since 2011. Fifteen years of continual maintenance, backwards compatibility, support, and the (very rare) security patch. That kind of stability requires sustainable funding, and dual-licensing is how we make it work without venture capital or rug-pulls. Support sustainable and secure software; swap patch tuesday for patch leap-year.
Your options:
- Startup license — $1 if your company has under $1M revenue and fewer than 5 employees. Get a key →
- Commercial subscription — Governed by the Imazen Site-wide Subscription License v1.1 or later. Apache 2.0-like terms, no source-sharing requirement. Sliding scale by company size. Pricing & 60-day free trial →
- AGPL v3 — Free and open. Share your source if you distribute.
See LICENSE-COMMERCIAL for details.
Upstream
Upstream code from libjxl/libjxl is licensed under BSD-3-Clause.
Our additions and improvements are dual-licensed (AGPL-3.0 or commercial) as above.
Algorithms and constants derived from libjxl (BSD-3-Clause).