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

Missing DPI infos in JXL format #817

Open
gorza47 opened this issue Nov 6, 2021 · 3 comments
Open

Missing DPI infos in JXL format #817

gorza47 opened this issue Nov 6, 2021 · 3 comments
Labels
cjxl Related to cjxl encoder tool container/metadata Related to part 2 (file format) unrelated to 1.0 Things that need not be done before the 1.0 version milestone

Comments

@gorza47
Copy link

gorza47 commented Nov 6, 2021

Most formats have image DPI infos in the file header, no such thing in JXL?
Converting PNG (with DPI infos in the file header) to JXL and back (using cjxl.exe and djxl.exe) => DPI infos are lost.

@jonsneyers
Copy link
Member

Do you mean the pHYs physical image dimensions that PNG files can have?

We don't have such a thing in the JPEG XL codestream headers; we did not consider it render-impacting metadata since in practice, most viewers would not try to render an image at some specific physical dimension, but rather they would typically show it at dimensions dictated by CSS (in case of browsers), whatever the pixel density of the screen is (in case of most viewers if the image is smaller than the screen), or just scaled to fit the screen (in case the image is larger than the screen). The DPI info is maybe somewhat relevant for printing use cases but in most cases also there it has become a rather meaningless piece of info.

Anyway, if you want to keep it, you can do it by using Exif or XMP metadata, which does have that field. I'm sure there must be some way to use exiftool or exiv2 to get the DPI from the png pHYs chunk and add XMP data with the same information (or update the XMP to add that information, if there is already XMP data in the png).

I suppose in cjxl, when given png input, we could look for the pHYs png chunk and translate it to a corresponding Exif or XMP blob (or add it to a blob if there is already one). That's quite a messy thing to do though (it involves adding Exif or XMP manipulation functionality to cjxl, which currently we've managed to mostly avoid with the only exception being Exif orientation).

@jonsneyers jonsneyers added cjxl Related to cjxl encoder tool container/metadata Related to part 2 (file format) labels Nov 8, 2021
@gorza47
Copy link
Author

gorza47 commented Nov 8, 2021

Yes, pHYs in PNG ... or any other format with DPI/resolution infos.

OK, it would be great to save/read these infos.

Yes, the easiest way is probably to use Exif metadata tags of a JXL file:
0x11A = XResolution
0x11B = YResolution

Are there nice/simple APIs to read/write such Exif tags in a JXL file?

Thanks!

@kmilos
Copy link

kmilos commented Nov 12, 2021

Yes, the easiest way is probably to use Exif metadata tags of a JXL file:
0x11A = XResolution
0x11B = YResolution

Btw, there is a minimal set of required tags to comply w/ Exif spec, you can't just add these two. For compressed images, these should also be present:

ResolutionUnit
YCbCrPositioning (I guess this was for JPEG only?)
ExifVersion
ComponentsConfiguration (also JPEG only specific?)
ColorSpace
PixelXDimension
PixelYDimension

@mo271 mo271 added the unrelated to 1.0 Things that need not be done before the 1.0 version milestone label Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cjxl Related to cjxl encoder tool container/metadata Related to part 2 (file format) unrelated to 1.0 Things that need not be done before the 1.0 version milestone
Projects
None yet
Development

No branches or pull requests

4 participants