Exiv2 / exiv2

Image metadata library and tools
http://www.exiv2.org/
Other
893 stars 279 forks source link

JXL/codestream support #1506

Open clanmills opened 3 years ago

clanmills commented 3 years ago

There is thorough discussion of the emerging JXL standard in #1503.

JXL can have two different file structures.

  1. JXL/bmff The file is bmff formatted. Adding support for this format in tvisitor.cpp (the code in my book) required less than 30 lines of code. The effort in Exiv2 will be similar. The jxlc box contains the codestream. The metadata is stored in the boxes Exif and xml. The specification of brotli compressed metadata boxes is still in discussion.

    It's likely that Exiv2 will be able to support JXL/bmff in 2021 as the effort required is modest. Support for the brotli compressed metadata will follow when the standard is defined.

  2. JXL/codestream This is a JPEG style stream which begins with the marker 0xff0a. It does not contain Exif of XML metadata. It can contain an ICC profile. Implicit metadata such as the image and orientation are in the code stream.

    The effort to recover the ICC profile from the codestream is the substance of this issue report. It's unlikely that the engineering resources will be available in 2021 to tackle this issue. I have assigned this issue to Milestone v0.28 to make it visible during the v0.28 project life. However, it will probably be deferred.

clanmills commented 3 years ago

There is a brief discussion about the patent situation concerning BMFF/JPEG-XL here: #1679

antermin commented 1 year ago

The following is an example of how to decode the image dimensions of a JXL/codestream file:

https://github.com/Fraetor/pyjxl/blob/7fa61cfb268de422c41727267c02dec1f199dc94/src/pyjxl/decode_jxl.py#L19-L72

antermin commented 1 year ago

It's a PoC because I am a total beginner in programming:

I referred to the following for the code:

Please feel free to adopt and improve the patch / write a better one.


Edit: Please see below for latest updates.

antermin commented 1 year ago

Update: I have updated my fork so that it parses the jxlp and jxlc boxes in JXL/bmff files to get the dimensions. In other words, if a JXL/bmff file does not have Exif dimensions metadata (or when exiv2 cannot read the Exif metdata, such as no Brotli support), my fork can probably display it now during exiv2 pr.

If a JXL/bmff file has Exif dimensions metadata, exiv2 prioritizes it, so sometimes it may be inconsistent if:

I have also tried to backport the Brotli patch to 0.27:

Any kind of help would be greatly appreciated.

Note: I used 0.27 as the base, since I am not sure whether the main branch has changed the API (and requires code changes in other applications / libraries).

kmilos commented 1 year ago

Thanks for working on this!

Note: I used 0.27 as the base, since I am not sure whether the main branch has changed the API (and requires code changes in other applications / libraries).

IMHO I don't think we really want to introduce new features to 0.27 branch, only security and bug fixes, but I could be wrong... @nehaljwani

antermin commented 1 year ago

I have rebased my PoC code on top of the main branch.