jpegli-rs
Pure Rust implementation of jpegli - Google's improved JPEG encoder/decoder from the JPEG XL project.
Features
- Pure Rust - No C/C++ dependencies required
- Perceptual optimization - Uses adaptive quantization for better visual quality
- Backward compatible - Produces standard JPEG files readable by any decoder
- SIMD accelerated - Uses
widecrate for portable SIMD - Color management - Optional ICC profile support via lcms2
What is jpegli?
jpegli is Google's improved JPEG encoder that produces smaller files at the same visual quality, or better quality at the same file size. It achieves this through:
- Adaptive quantization - Content-aware bit allocation
- Improved quantization tables - Better than standard IJG libjpeg tables
- XYB color space (optional) - Perceptually optimized color representation
- Smart zero-biasing - Intelligent coefficient rounding
Usage
use ;
// Encode RGB image data to JPEG
let jpeg_data = new
.width
.height
.pixel_format
.quality // Q90
.encode?;
// Write to file
write?;
Feature Flags
simd(default) - Enable SIMD accelerationcms(default) - Enable color management (uses lcms2)cms-lcms2- Use lcms2 for color managementcms-moxcms- Use moxcms for color management (pure Rust)
Performance
jpegli-rs achieves 10-17% better quality (measured by DSSIM) at the same file size compared to mozjpeg, or produces 5-8% smaller files at equivalent quality.
License
BSD-3-Clause, same as the original jpegli.
Acknowledgments
This is a Rust port of jpegli from the JPEG XL project by Google.
AI-Generated Code Notice
This crate was developed with significant assistance from Claude (Anthropic). While extensively tested against the C++ reference implementation with 100+ parity tests, not all code paths have been manually reviewed.
Before production use in critical applications:
- Review code paths relevant to your use case
- Run your own validation tests
- Report any issues at https://github.com/imazen/jpegli-rs/issues