PetrVys / MotionPhoto2

Mux HEIC and JPG Live Photos into Google/Samsung Motion Photos
MIT License
16 stars 4 forks source link

Merged HEIC photos are not detected as HDR by Google Photos #2

Open PetrVys opened 4 weeks ago

PetrVys commented 4 weeks ago

When merged photo is uploaded to GPhotos, it is not tagged as HDR.

Investigate if this can be caused by the XMP tag differences (the program tries to copy the HDR tags, but it does not create the same namespace alias, when it fails it does so silently etc.). If the problem cannot be tracked back to XMP changes of HEIF image, then it probably needs to reside in another place for Google/Samsung images :-(

PetrVys commented 4 weeks ago

~It seems that any change of XMP data by exiftool causes the image to lose HDR...~

PetrVys commented 4 weeks ago

Correction: If the XMP data contains the GCamera tags (MotionPhoto etc.), then Google Photos themself will stop looking for Apple HDR information. If you add any other tag (for example standard EXIF tags in XMP), then it works just fine (but cannot be recognized as Motion Photo). The reason is probably that the same GCamera namespace includes support for incompatible gain map HDR format.

If you save the photo back to iPhone, it's still HDR. Sometimes, because GPhoto saves the photo in both JPG and HEIF format, HDR will not show even in photos app. In that case, edit the picture and immediately discard changes, HDR should show up then. Funnily enough, if you download the image to phone, kill GPhotos and launch it again, it'll usually show the image in HDR too - but it has to be saved locally on iPhone for that to work.

The way to overcome this would theoretically be to remux the HDR information into google-specific ways... But unless someone can point me to some code, it's a very tall order...

It also seems that the Google/Adobe gain map format only applies to JPG images...

Links: https://developer.android.com/media/platform/hdr-image-format https://www.reddit.com/r/jpegxl/comments/1c04fh5/how_does_hdr_in_jxl_work/ https://rioogino.com/posts/2024/edr_1_photos/ https://gist.github.com/kiding/fa4876ab4ddc797e3f18c71b3c2eeb3a

PetrVys commented 4 weeks ago

Looking at AOSP source, I saw that namespace checking was not present, so I decided to try to fuzz it a bit to see if this could've helped (HDR code not seeing the tag and MotionPhoto seeing it). Unfortunately I must report that GPhoto server-side code is significantly better quality than Android, it works as it should (in case ns is incorrect, it is completely ignored, in case it is correct but unusual name, it works but turns off HDR)

NightMean commented 3 weeks ago

Thanks for looking into this on such deeper level. Just posting a reference where this discussion started. https://github.com/doodspav/motionphoto/issues/13#issuecomment-2291264369