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

Add reference to HDR gainmap to the GCamera XMP tag if present in the source image #15

Open
PetrVys opened this issue Oct 31, 2024 · 5 comments
Assignees

Comments

@PetrVys
Copy link
Owner

PetrVys commented Oct 31, 2024

When we mux iPhone 15 pro iOS18.1 JPG (e.g. containing urn:iso:std:iso:ts:21496:-1 gainmap metadata) into MotionPhoto, GPhoto does not recognize the resulting photo as HDR, although to the best of my understanding it should. Try to parse the gainmap position in the source file and reference it in XMP Item:Semantic="GainMap" record.

@PetrVys
Copy link
Owner Author

PetrVys commented Oct 31, 2024

I've tried hand-crafting one JPG file from live photo (sorry, taken at home, won't attach my GPS coords here :-) ), but the results are unfortunately mixed:

  • It is shown with HDR tag in GPhotos and "RICH CONTRAST" in iOS
  • But it does not actually render the HDR

I guess it does have something to do with the multipicture JPEG format, I'll need to look into (de/re)muxing it... Because the vanilla MotionPhoto produced by the script is not detected as HDR in GPhotos, but it is detected as Rich Contrast in iOS... but does not render in HDR either. So just adding bytes to the end of the file breaks the HDR format.

@PetrVys
Copy link
Owner Author

PetrVys commented Nov 1, 2024

changing MPF header has no impact - even when it is obviously wrong, everything still works without video... But as soon as video is added, it breaks.

Trying with ultrahdr_app from libultrahdr, I get error when decoding iPhone ISO HDR JPGs: received 0 (bad value) for field baseHdrHeadroom denominator, so the hdr values need to be probably adjusted. So much for universal standard :\

@PetrVys
Copy link
Owner Author

PetrVys commented Nov 1, 2024

So the urn:iso:std:iso:ts:21496:-1 structure is completely different between android and ios... it appears that ios is 8 bytes longer than what Android expects for 1-channel record and the fields do not seem to map in sensible way to each other. Looking at the data, it seems that iOS stores RGB 3-channel channel metadata in there, but that does not map into the libultrahdr fields either. I'll try to document it and raise it as libultrahdr issue...

@PetrVys
Copy link
Owner Author

PetrVys commented Nov 5, 2024

Ok, so... After the latest updates to libultrahdr (it was error in the library), it's possible:

demo.zip

Probably the first JPG HDR Motion Photo created from JPG HDR Live Photo, enjoy. I had to strip all tags from the files in order for the ultrahdr_app to work correctly, so no metadata apart from HDR in the MotionPhoto for now - but yay!

I'll need to work on this quite a bit to make it actually work in the script, though - the gainmap needs to be demuxed, metadata updated to google format and remuxed back into JPG, then the video footer needs to be added.

@PetrVys
Copy link
Owner Author

PetrVys commented Nov 5, 2024

unfortunately when GPhoto saves this MotionPhoto back to iOS camera roll, it loses everything and turns into pure JPG with no metadata and thus no HDR. But within GPhotos it works well.

@PetrVys PetrVys self-assigned this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant