JPEG XL (JXL) is a modern image format designed to be highly versatile, offering both superior lossless compression and the ability to losslessly recompress existing JPEG files. Here's how it achieves these feats, along with some context on why Google favored AVIF over JXL:
1. How JPEG XL Achieves High Lossless Compression
JPEG XL employs several advanced techniques to compress images losslessly:
- Modular Entropy Coding: Uses a flexible, context-adaptive arithmetic coder (ANS) that efficiently compresses image data.
- Predictive Coding: Predicts pixel values based on neighboring pixels, reducing redundancy before entropy coding.
- Variable Block Sizes: Adapts to image content by splitting it into optimal block sizes for better compression.
- Perceptual Modeling (Optional): Even in lossless mode, it can exploit perceptual redundancies to improve compression without altering the original data.
These methods allow JPEG XL to outperform formats like PNG, FLIF, and even WebP in lossless compression.
2. How JPEG XL Losslessly Recompresses JPEGs
JPEG XL can transcode existing JPEG files without quality loss by:
- Preserving the DCT Coefficients: Instead of decoding and re-encoding the image (which would introduce generation loss), JXL stores the original JPEG's DCT coefficients directly.
- Smart Metadata Handling: It efficiently repackages the JPEG data with better entropy coding, reducing file size by ~20% on average.
- Progressive Decoding: Unlike JPEG, JXL allows progressive decoding without artifacts, even when recompressed.
This makes JPEG XL an excellent archival format for legacy JPEGs.
3. Why Google Abandoned JPEG XL in Favor of AVIF
Despite JPEG XL's technical advantages, Google (and others like Apple) chose AVIF (based on AV1 video compression) for several reasons:
- Video Codec Synergy: AVIF is derived from AV1, which Google heavily invested in (via Alliance for Open Media, AOMedia). Reusing AV1's tools simplifies development.
- Royalty-Free Licensing: AV1 (and thus AVIF) is backed by major tech companies (Google, Netflix, Amazon, etc.), ensuring no patent risks.
- HDR & Wide Gamut Support: AVIF was designed with modern display needs in mind (10/12-bit color, HDR), while JXL's HDR support was still evolving.
- Political & Ecosystem Factors: Google already had WebP (VP9-based) and wanted to push AVIF as a successor, rather than adopt a competing format (JXL was developed by the JPEG committee).
- Performance Concerns (Debatable): Some argued AVIF decoding was slower, but hardware acceleration (via AV1 decoders) was prioritized.
4. The Aftermath: JPEG XL vs. AVIF
- AVIF excels in lossy compression (especially for HDR/10-bit images) but struggles with lossless and JPEG recompression.
- JPEG XL is more versatile (lossless, lossy, JPEG recompression, progressive decoding) but lacks industry backing.
- Chrome's Rejection: Google controversially removed JXL support from Chrome, citing low ecosystem interest—despite Mozilla and Cloudflare supporting it.
Conclusion
JPEG XL is technically superior for lossless and JPEG recompression, but AVIF won due to corporate alliances and video codec synergy. The decision was more about business strategy than pure technical merit. However, JPEG XL remains a strong option for archival and professional use cases where its flexibility matters.