A complete reference implementation of JPEG XL (ISO/IEC 18181) in Rust, based on the libjxl C++ reference implementation.
Developed by: Greg Lamberson, Lamco Development Contact: greg@lamco.io Repository: https://github.com/lamco-admin/jxl-rust-reference
This project provides a pure Rust implementation of the JPEG XL image format, including both encoder and decoder functionality. The implementation follows the ISO/IEC 18181 standard and is structured to match the architecture of the official libjxl reference implementation.
Official C++ Reference: https://github.com/libjxl/libjxl (v0.11.1)
This Rust implementation is based on libjxl's architecture and design but reimplemented idiomatically in Rust with focus on:
- Memory safety
- Type safety
- Modern Rust patterns and best practices
- Performance through zero-cost abstractions
This is a Cargo workspace containing multiple crates:
- jxl-core: Core data structures, types, and common utilities
- jxl-bitstream: Bitstream reading/writing and entropy coding (ANS)
- jxl-color: Color space transformations and XYB color space
- jxl-transform: DCT, prediction, and image transformations
- jxl-headers: Header parsing and metadata handling
- jxl-decoder: JPEG XL decoder implementation
- jxl-encoder: JPEG XL encoder implementation
- jxl: High-level API for easy use
- Lossless and lossy compression
- Support for multiple bit depths (8-bit, 16-bit, float)
- HDR and wide color gamut support
- Progressive decoding
- Animation support
- JPEG reconstruction mode
- Multi-threaded encoding/decoding
JPEG XL (ISO/IEC 18181) consists of:
- Part 1: Core codestream specification
- Part 2: File format (.jxl)
- Part 3: Decoder conformance requirements
- Part 4: Reference software (libjxl)
This is an EDUCATIONAL reference implementation. It demonstrates JPEG XL architecture in Rust but does NOT produce or decode compliant JPEG XL files.
📖 Read LIMITATIONS.md for full details on what is and isn't implemented.
For production use:
# Clone the repository
git clone https://github.com/lamco-admin/jxl-rust-reference.git
cd jxl-rust-reference
# Build the project
cargo build --release
# Run tests
cargo test --all
# Run examples
cargo run --example encode_decode # Basic encoding/decoding
cargo run --example pixel_formats # Different pixel formats
cargo run --example error_handling # Error handling patterns
# Run benchmarks
cargo benchFor detailed build instructions, see BUILD-AND-TEST.md.
- LIMITATIONS.md -
⚠️ Read this first! Explains scope and what's implemented - IMPLEMENTATION.md - Technical architecture and algorithm details
- BUILD-AND-TEST.md - Comprehensive build and testing guide
- CONTRIBUTING.md - How to contribute
- EVALUATION.md - Critical evaluation of implementation
use jxl::{JxlDecoder, PixelFormat};
let decoder = JxlDecoder::new()?;
let image = decoder.decode_file("image.jxl")?;use jxl::{JxlEncoder, EncoderOptions};
let encoder = JxlEncoder::new()?;
let options = EncoderOptions::default()
.quality(90.0)
.effort(7);
encoder.encode_file(&image, "output.jxl", options)?;This implementation complements the existing JPEG XL ecosystem:
- libjxl: Official C++ reference implementation (encoder and decoder)
- jxl-oxide: Spec-conforming Rust decoder (decoder only)
- jxl-rust-reference (this project): Rust reference implementation (encoder and decoder)
BSD 3-Clause License (matching libjxl)
Copyright (c) 2025 Greg Lamberson, Lamco Development
- JPEG XL Official Website
- libjxl Reference Implementation
- JPEG XL Specification
- ISO/IEC 18181:2022 Standard
Contributions are welcome! This is a reference implementation designed to be educational and complement the official libjxl C++ implementation. For production use, consider libjxl or jxl-oxide.