Adding tag on JPEG XL image corrupts its metadata

Started by boinjyboing, August 14, 2024, 01:35:08 PM

Previous topic - Next topic

boinjyboing

The image file is still viewable, so it's not the end of the world, but it'd still be good to find out what is happening.

System type = Windows, cmd.exe

exiftool 12.92


Start with a jpg file with nontrivial exif data. For example, any jpg created by an iphone 13 pro camera.

Losslessly convert the jpg to jxl.
    cjxl sample.jpg sample.j.jxl
Add a Copyright to the jxl
    exiftool sample.j.jxl -Copyright=nnnnnnnnnnnnnnn -o samplemodified.j.jxl

The output file has bad metadata that can't be read by djxl.

Converting back to jpg is succesful for the original file
    djxl sample.j.jxl sample-back.jpg
"Reconstructed to JPEG."


Converting back to jpg is *not* succesful for the new file
    djxl samplemodified.j.jxl samplemodified-back.jpg
"Failed to decode image"
"could not decode losslessly to JPEG"

I'm using Windows, libjxl 0.10.3 and exiftool 12.92.

Phil Harvey

This may be difficult to solve.  A quick comparison of the file you attached before and after adding Copyright with ExifTool 12.92 shows no significant differences.  ExifTool can read both just fine.

1. Could you try removing copyright afterwards with -copyright= to see if djxl has problems with this?

2. Do you have other jxl utilities?  Do they have problems with the edited file?  If not, I suggest sending the problem file to the libjxl people to see what they say.

One interesting thing is that the uncompressed Exif is 7980 bytes in the original file, and 8010 bytes after editing (makes sense since the Copyright was added).  However, the Brotli-compressed Exif is 6452 bytes in the original, and 6340 bytes in the edited version (it gets smaller!).  It seems that the Brotli library that ExifTool is using is compressing more efficiently.  I wonder if a Brotli version difference could be the problem?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).