I was recently reading about the JPEG XL format, which is one of the promising options for replacing a venerable JPEG standard.
One of the aspects underlined in several sources is that it’s possible to losslessly transcode JPEG to JPEG XL and reduce the size of a file. What I found interesting is the possibility of converting the file back to the source JPEG without losing even a bit of the original information.
How to actually do it?
The talk is cheap, but finding a tool that can perform such a conversion took me some time. Here are the steps, though:
- Download a reference implementation of JPEG XL for your OS. For me, it was the jxl-x64-windows-static package.
- Convert your file using
cjxl.exe
encoder from the package:cjxl.exe input.jpg output.jxl
- Convert your file back using
djxl.exe
decoder:djxl.exe output.jxl
input-restored.jpg
- Note that
input.jpg
and
are indeed bit-perfect.input-restored.jpg
I was also trying to achieve the same using the ImageMagick tool, which is a more practical tool to work with images, but I don’t think such lossless transcoding is supported at the moment.
Thoughts and comments
It’s not surprising that new formats can achieve much better compression ratios. But I found it interesting that there is so much redundancy in JPEG that even a lossless compression can gain us significant benefits.
To put that in context, you can compare the compression ratio with popular archive types like zip or 7zip (with their “ultra” compression mode):
It’s uncertain if the JPEG XL format will gain traction and widespread support as it competes with quality alternatives like AVIF and WEBP. But this legacy-friendly feature could still make it useful in some use cases. For example, efficient archiving of JPEG attachments uploaded by users that we must retain unmodified for later retrieval.
No comments yet, you can leave the first one!