libultrahdr icon indicating copy to clipboard operation
libultrahdr copied to clipboard

Add support for encoding JPG as ISO 21496-1

Open gregbenz opened this issue 1 year ago • 1 comments

It appears the ISO gain map spec has progressed to draft international standard (https://www.iso.org/standard/86775.html), so I wanted to create a thread to facilitate discussion.

I believe the following will all be high value for libultra to support (ordered with most important first):

  1. encode to ISO JPG. This is most important for content creation and is of course a prerequisite for the next item (transcoding).
  2. transcode from supported gain map formats (Ultra HDR now, but ideally Apple too to support existing content from phone captures) to ISO JPG. For transcoding, as long as the image is not being mutated (cropping, etc), the output should be lossless (relative to the existing gain map). I presume all the metadata should map cleanly, and not recalculating the images is ideal for speed as well as quality.
  3. decode ISO JPG.

gregbenz avatar Sep 12 '24 00:09 gregbenz

Adobe's gain map page now refers to the ISO spec and contains sample JPG images which appear to use it (per the optional info overlay in the updated demo app on that page). https://helpx.adobe.com/camera-raw/using/gain-map.html

gregbenz avatar Oct 04 '24 21:10 gregbenz

I've added a sample ISO JPG here (currently listed as test 8a): https://gregbenzphotography.com/hdr/#tests

The latest ACR / LR updates from Adobe are able to export ISO gain maps for JPG, AVIF, and JXL.

gregbenz avatar Oct 16 '24 14:10 gregbenz

@gregbenz setting this to true should resolve this request.

ram-mohan avatar Oct 29 '24 20:10 ram-mohan

@ram-mohan Thanks!!

gregbenz avatar Oct 29 '24 21:10 gregbenz

Are there plans to switch the flag on? Is this blocked on finalization of ISO 21496-1?

koto avatar Nov 17 '24 19:11 koto

@koto android recommends writing both xmp and iso metadata. details here. We have added a pr #329 to take care of this. thank you.

ram-mohan avatar Nov 19 '24 09:11 ram-mohan

Does Android use libultrahdr in camera app? Wondering why a photo taken from Android 15 has XMP but no ISO metadata.

Image

While the adobe gain map sample JPEG is opposite, has ISO but no XMP.

Image

Haven't found one JPEG with both XMP and ISO on internet 🤣

mgenware avatar Nov 19 '24 10:11 mgenware

@mgenware A dual encoded image shows in the Adobe Gain Map Demo app as supporting ISO and does not mention there is valid XMP data (ie, it references the preferred data when both are present).

I have updated to latest Android 15 and Pixel camera as of today and do not see ISO encoding of the gain maps created with a Pixel 8 Pro, only the Android XMP encoding.

But it is encoded elsewhere. Latest Apple software dual encodes the Apple XMP + ISO. Latest Adobe LR / ACR dual encodes the Adobe XMP + ISO.

I can see both the Adobe XMP and ISO in the files I test. The tool you are using likely isn't reporting that both are present (which would be consistent with Adobe's gain map demo app). It would be nice if these tools listed any valid fallback metadata, but it seems they just report the primary supported encoding when both are available (ie, consistent with how a decoder should work if it understands the ISO encoding).

gregbenz avatar Nov 21 '24 17:11 gregbenz

@gregbenz thanks for the info! I can confirm iOS 18 JPEG and HEIC are both dual encoded.

HEIC: Image

JPEG: Image

mgenware avatar Nov 22 '24 03:11 mgenware