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

JXL/codestream support #1506

Open
clanmills opened this issue Mar 25, 2021 · 6 comments
Open

JXL/codestream support #1506

clanmills opened this issue Mar 25, 2021 · 6 comments
Labels
help wanted imageHandler Anything related to specific ImageHandlers request feature request or any other kind of wish
Milestone

Comments

@clanmills
Copy link
Collaborator

clanmills commented Mar 25, 2021

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 clanmills added this to the v0.28 milestone Mar 25, 2021
@hassec hassec added enhancement feature / functionality enhancements refactoring Cleanup / Simplify code -> more readable / robust request feature request or any other kind of wish and removed refactoring Cleanup / Simplify code -> more readable / robust enhancement feature / functionality enhancements labels Apr 8, 2021
@clanmills
Copy link
Collaborator Author

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

@antermin
Copy link

antermin commented Mar 10, 2023

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

@kmilos kmilos added imageHandler Anything related to specific ImageHandlers help wanted labels Mar 11, 2023
@antermin
Copy link

antermin commented Mar 13, 2023

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

  • Not sure whether the correct data / variable types are used.
  • Copied getUint64_t from asfvideo.cpp. I don't know how to reuse that function properly.
  • No autotests.
  • The Visual Studio project files are not touched. (Only tried it on Linux)
  • Coding style issues

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
Copy link

antermin commented Mar 17, 2023

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:

  • Exif dimensions are not the same as actual image dimensions (e.g. the image has been downscaled, but the Exif tags are not updated)
  • The image has been rotated (e.g. Exif says 1920x1080 but the actual may be 1080x1920)

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

  • Brotli-compressed Exif seems to work
  • Brotli-compressed XML/XMP doesn't - it looks like the first few bytes (the beginning of XMP packet) are incorrect / corrupted when I added the debug code to dump the bytes.

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
Copy link
Collaborator

kmilos commented Mar 17, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted imageHandler Anything related to specific ImageHandlers request feature request or any other kind of wish
Projects
None yet
Development

No branches or pull requests

5 participants