Skip to content
Blog

Can you recover the original JPEG from a JXL file?

Try a byte-for-byte recovery on a sample JPEG XL archive and learn when you need a fresh export.

If an archive was migrated to JPEG XL, you may be able to hand back the exact JPG that went in. The answer depends on how the JXL was created.

Two kinds of input

A JXL made by reversible JPEG transcoding can store reconstruction data. A JXL encoded from pixels, perhaps from a PNG, has a different history. Even lossless pixels can't recreate a previous JPG's metadata and byte sequence by themselves.

We used libjxl 0.11.1 to reversibly transcode a 161,833-byte JPEG. The resulting JXL was 133,665 bytes. Other archives will give different sizes.

Restore and compare

The first command shows how we made the sample. If you already have the JXL, start with djxl. Save the example downloads as archive.jxl and original.jpg and write to a fresh filename. Our decoder reported “Reconstructed to JPEG”.

cjxl original.jpg archive.jxl --lossless_jpeg=1
djxl archive.jxl restored.jpg

On macOS or Linux, cmp original.jpg restored.jpg exits silently with status 0 for identical files. On Windows compare both SHA-256 values in PowerShell. All 161,833 bytes matched in this test.

Get-FileHash original.jpg, restored.jpg -Algorithm SHA256

SHA-256 of both the source and restored JPEG:

eb23f84f3f38b7e06f0ed73673a57b4b267668aed1633ff01846ddd1f32c1ed7

Export when reconstruction isn't available

If the JXL opens but contains no recovery information, export a new JPEG from its pixels. Here is a starting point for an ordinary opaque still photo.

djxl input.jxl copy.jpg --pixels_to_jpeg --jpeg_quality=90

Reopen the copy and check orientation, dimensions, detail and colour gradients. Choose a background in an editor for transparent content. Keep the JXL for any transparency, animation or other data a regular JPEG can't hold.

Files and further reading