Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lossless conversion of JPEG and PNG files to JPEG XL #62

Open
veikk0 opened this issue Apr 11, 2023 · 1 comment
Open

Support lossless conversion of JPEG and PNG files to JPEG XL #62

veikk0 opened this issue Apr 11, 2023 · 1 comment

Comments

@veikk0
Copy link

veikk0 commented Apr 11, 2023

A useful feature of JPEG XL is support for losslessly transcoding JPEG files into JPEG XL. This reduces file size by 20% on average, and the process is also reversible, so you can losslessly convert back to the original JPEG data.

JPEG XL also does "normal" lossless compression, so PNG files can be losslessly converted as well (about 35% size reduction, 50% for HDR).

The reference implementation is libjxl, and it's the best encoder so far. The conversion executable is cjxl, and the usage is cjxl INPUT OUTPUT [OPTIONS...]. The effort/CPU time used for conversion is controlled with -e. Higher numbers result in more processing time and higher compression efficiency. The default is 7, and if necessary, conversion can be made significantly faster with lower values. In my experience, libjxl is impressively fast.

This might be a long-term feature request, but being able to convert to JPEG XL for lossless optimization would be useful. Even though JPEG XL support isn't universal yet, it's so much superior to the competition that it's only a matter of time. The codec is in it for the long haul and was designed as a long-term replacement for JPEG (which is now 30 years old) as well as PNG, unlike the WebM/AVIF style of web-centric codecs that want to introduce a new codec every few years if possible.

libjxl itself is easy to install, with static builds for Windows and Linux as well as .deb packages for Debian and Ubuntu available on the releases section. It's also available on Homebrew for MacOS.

@ajslater
Copy link
Owner

ajslater commented Feb 19, 2024

This is planned for the future, but with the lack of current JPEG XL proliferation and tooling at the moment it's still on the shelf.

Hurray for Safari! https://caniuse.com/jpegxl
How often does Apple lead with format support? Weird.

I'd probably press go on implementation once Pillow supports it: python-pillow/Pillow#4247
But if browser support happens before that I'll bite the bullet and do my own format detection and metadata insertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants