cjxl
Encode or decode JPEG XL images
TLDR
Convert an image to JPEG XL
Set quality to lossless and maximize compression of the resulting image
Display an extremely detailed help page
SYNOPSIS
cjxl [options] input_file output_file
PARAMETERS
-d, --distance NUM
Sets the target Butteraugli distance for lossy compression. 0 for lossless. Higher values mean more compression, lower quality. (Default: 1.0)
-q, --quality NUM
Sets a JPEG-like quality setting (0-100). Correlates with --distance but is more user-friendly. Higher values mean better quality.
-e, --effort NUM
Controls the encoding effort/speed (1=fastest, 9=slowest/best compression). Higher effort yields smaller files but takes longer. (Default: 7)
-s, --speed NUM
Alias for --effort.
--modular
Forces modular mode (lossless encoding). Useful for synthetic images or when --distance is 0.
--container
Forces the use of the JXL container format, which enables features like animations or embedded JPEG bitstreams.
--jpeg_recompress
Losslessly recompress a JPEG file to JXL. The original JPEG bitstream is optionally embedded for backward compatibility.
--num_threads NUM
Specifies the number of threads to use for encoding. (Default: based on CPU cores)
-h, --help
Displays help message and exits.
--version
Displays version information and exits.
DESCRIPTION
The cjxl command is the official command-line encoder for the new JPEG XL (JXL) image format. JPEG XL is a royalty-free, next-generation image coding system designed for superior compression efficiency and rich functionality. cjxl converts various input image formats (e.g., PNG, JPEG, GIF, PPM, TIFF) into highly optimized JXL files. It supports both lossy and lossless compression modes, allowing users to balance file size with image fidelity. Key features include support for animated images, progressive decoding, and the ability to losslessly recompress existing JPEG files into JXL, potentially reducing their size without quality loss while maintaining the original JPEG data within the JXL stream for backward compatibility. Its versatility makes it suitable for web delivery, photography, and archival purposes.
CAVEATS
Encoding with cjxl, especially at higher --effort settings, can be computationally intensive and time-consuming. While JPEG XL generally offers superior compression at high qualities, for very low-detail images at extremely low target sizes, older formats might occasionally yield smaller files or faster encoding. Browser and software support for JPEG XL is growing but might not be universal yet.
INPUT/OUTPUT FORMATS
cjxl accepts a wide range of input image formats including PNG, JPEG, GIF, PPM, and TIFF. The output is always a JPEG XL file with the .jxl extension. It can also handle multi-frame inputs for animation encoding.
LOSSY VS. LOSSLESS
By default, cjxl operates in a lossy mode optimized for perceptual quality using the Butteraugli metric (controlled by --distance). Setting --distance 0 or using the --modular option forces lossless compression, ensuring no data is discarded.
HISTORY
JPEG XL (JXL) is a modern, royalty-free image format developed by the Joint Photographic Experts Group (JPEG) committee. Its development began in 2017, and it was officially standardized as ISO/IEC 18181 in October 2021. The cjxl encoder is part of the reference implementation library, libjxl, which was designed to be highly optimized and serve as a successor to legacy image formats like JPEG, PNG, and GIF, aiming to provide better compression and more features.