Aug 03

Compress JPGs like crazy with JPEG XL

Category: Linux,multimedia,Tools   — Published by goeszen on August 3, 2025 at 5:28 pm

Having a large archive of JPEG images is a beast that is difficult to tame. Compressors like ZIP, RAR or more modern CLI tools like bzip2, lzma or zstd will only be able to shave of a few KBs on arbitrary JPG files.

But did you know that converting them to the newer JPEG-XL standard can boil down file sizes somewhere around -20%! And that in a way that is still easily viewable by common image viewers (at least on Linux) and in a way where you can easily restore the original input JPG, pixel-perfect and exactly as it was, bit-by-bit! Believe it or not.

First: install jpeg-xl and related tools

You can download the official releases from the JPEG-XL repo on github:

https://github.com/libjxl/libjxl/releases

On Ubuntu, package availability is sparse, so you may download the tar. It contains:
./jxl_0.11.1_amd64.deb
./libjxl-dev_0.11.1_amd64.deb
./jxl-dbgsym_0.11.1_amd64.ddeb
./libjxl-gimp-plugin-dbgsym_0.11.1_amd64.ddeb
./libjxl-gimp-plugin_0.11.1_amd64.deb
./libjxl-dbgsym_0.11.1_amd64.ddeb
./libjxl-gdk-pixbuf-dbgsym_0.11.1_amd64.ddeb
./libjxl-gdk-pixbuf_0.11.1_amd64.deb
./libjxl_0.11.1_amd64.deb

Start by installing the library and then the tools package:
$ sudo gdebi libjxl_0.11.1_amd64.deb
$ sudo gdebi jxl_0.11.1_amd64.deb

Similarly as in the previous article, Associate .avif files with your image viewer, on Ubuntu, add the pixbuffer loader to enable your image viewers to automagically be able to open .jxl files:
$ sudo gdebi libjxl-gdk-pixbuf_0.11.1_amd64.deb

See the .jxl size compression round-trip in action

$ cjxl example.jpg example.jxl
$ djxl example.jxl example_restored.jpg

and compare the restored image with the original xample.jpg:

$ cmp example.jpg example_restored.jpg

Getting zero output means the file is bit by bit the same, all complete with metadata headers, embedded color profiles etc! Great, isn't it?

A little bit of background on JPEG XL

How future proof is jpeg XL?

JPEG XL is VERY future-proof. It was designed from the ground up to address the limitations of older formats like JPEG, PNG, and even WebP, while anticipating the needs of modern and emerging workflows.
The reason for JPEG XL being so future-proof is its wide feature set. JPEG-XL supports high dynamic range (HDR), wide color gamuts, animation, alpha transparency, and even progressive decoding with saliency-based prioritization. Offers Lossless JPEG transcoding (as we demonstrated here) so you can convert existing JPEGs to JPEG XL with ~20% size savings and be able to reverse the process without any loss! JPEGXL supports up to 4099 channels for things like selection masks, spot colors, and CMYK workflows. It achieves high fidelity at lower bitrates than AVIF or WebP, making it ideal for both web and print and JPEGXL can be decoded in iterations, meaning you can show parts of an image with just 15% of the data loaded, which is great for slow connections or mobile devices or for thumbnail previews.

And what about AVIF?

Yes, AVIF is also very modern and very efficient - but different.

So, is JPEG XL the same as AVIF?

No. They’re competitors, not siblings. JPEG XL is developed by the JPEG committee, while AVIF is based on the AV1 video codec from the Alliance for Open Media.

Do we know why AVIF landed in browsers earlier than JPEG XL?

Yes, AVIF had the right mix of timing, support, and simplicity to win the browser race - at least in the first round. AVIF was backed by Big Tech. Being based on the AV1 video codec, developed by the Alliance for Open Media - consortium including Google, Amazon, Netflix, and Microsoft - gave AVIF a strong push into platforms like Chrome, Firefox, and Safari. And since AVIF uses AV1, browsers that already supported AV1 video playback could more easily integrate AVIF image decoding. On top, it AVIF’s licensing made it attractive for browser vendors to adopt without legal or financial hurdles.

But the tide is slowly turning and the momentum is shifting in subtle but meaningful ways towards JPEG XL. Tools like GIMP, Krita, ImageMagick, and Affinity Photo now support JPEG XL natively, making it easier for creators to adopt. And Microsoft released an official JPEG XL extension for Windows. The most important change may be the adoption by Apple: Apple added support in iOS 16 and JXL is supported in Apple browsers. Finally, communities focused on photography, archiving, and web performance are increasingly advocating for JPEG XL due to its ability to combine JPEG and RAW workflows into a single file. So we will see if Google brings back JXL support in Chrome, which it has droipped in 2023, followed by an outcry of the community.

More to read:
- Associate .avif files with your image viewer, on Ubuntu
- OptiJPEG - how to optimize JPG images losslessly

Leave a Reply

=