How to preserve colorspace? #5445
Replies: 7 comments 29 replies
-
See A Word About Color Spaces at https://imagemagick.org/script/formats.php where it says that HDR only supports linear RGB. May not be relevant if your Rec2020 color space is linear RGB or it could be an oversight. But you would be better assigning profiles for it rather than rely upon it being copied as such. See the list of colorspaces at https://imagemagick.org/script/command-line-options.php#colorspace. I do not see Rec2020. So it likely is not supported and is subsituted with RGB. However, you could request an enhancement for it. But again a profile may be better. The IM developers will need to comment further about this |
Beta Was this translation helpful? Give feedback.
-
Regarding colorspaces and profiles: IM has those two methods for defining in metdata what pixels values mean, and converting pixel values from one meaning to another. Two systems is not better than one, but they came about in the long evolution of IM. We are where we are. Most "colorspaces" are really colour models, such as XYZ, YIQ, HCL and so on. But some such as Adobe98, RGB, sRGB are real colorspaces, in the sense that they have colorimeric definitions. IM does some limited automatic conversion between colorspaces, for example, IM knows that CMYK data can't be stored in PNG files, so will automatically convert it to sRGB first. But most operations are purely numeric. For example, we might subract an sRGB image from a HCL image, to get a (probably) meaningless result. Near the top of verbose info we have:
That refers to the "-colorspace" setting. It has no connection to any embedded profile. IM has no "colorspace unknown" setting. Unless it knows otherwise, it assumes the colorspace is sRGB. For example, we might convert to a XYZ profile, and the "colorspace" setting will still claim the image is sRGB. If we want, we might "-set colorspace XYZ". |
Beta Was this translation helpful? Give feedback.
-
Did you try to add the profile as I suggested above.? |
Beta Was this translation helpful? Give feedback.
-
You say you are using "7.1.0-45 Q16-HDRI x64".
If your source is 32-bit integer, then IM will rescale the values in memory to 16-bit integer.
IM doesn't request a profile for any particular file format. Perhaps what you mean is "When writing an image with embedded profile to HDR format, IM should warn that the profile won't be written." Well, perhaps, but most file formats do not record all the metadata that IM has about an image. If IM warned about metadata that would not be written, IM would become very complex, and people would complain about the large number of messages. |
Beta Was this translation helpful? Give feedback.
-
What explicit request is being ignored? In your command ...
... the input file is read into memory. Then if the image has an embedded profile it is converted to a new profile, otherwise the profile is assigned to the image. Then the image is written to a file. These operations all succeed. No request is ignored.
Wikipedia suggests the defining document is https://floyd.lbl.gov/radiance/refer/filefmts.pdf , which describes the "Picture File Format", which has no facility to record ICC colour profiles. Each pixel is recorded with a total of 4 bytes (32 bits). It says:
I would regard an accuracy of 1% as totally horrid. It is similar to 8-bit integer. Okay, HDR format has a wider dynamic range, but at great cost. |
Beta Was this translation helpful? Give feedback.
-
Okay, I see what you mean. IM performs each operation separately. An image can be assigned or converted to an ICC profile, and the profile is embedded. An image (with or without an embedded ICC profile) can be saved to a file. If the file format doesn't support ICC profiles, then any embedded profiles won't be saved in the file. The same applies to other metadata; not all file formats can record all metadata. These are separate operations. When an image with embedded profile is saved to a file, IM doesn't know or care if the profile was embedded earlier in the same command, or in a previous IM command, or by a camera, or whatever. |
Beta Was this translation helpful? Give feedback.
-
@snibgo Thank you for that explanation, makes sense. Ultimately, I think the ideal solution for HDR processing will be to have support for JPG / AVIF gain maps with standard profiles (which in the case of an AVIF HDR base image includes PQ / HLG EOTF with common primaries, probably encoded as CICP rather than an ICC profile). At this point, those gain map formats are much more relevant than 32-bit TIF for tools intended primarily to support online sharing of images (I would not use 32-bit input or output with ImageMagick now, re-processing of an existing gain map is more relevant now to provide much better adaptation to displays of different capabilities). Request for gain map support: #6377 |
Beta Was this translation helpful? Give feedback.
-
I'm doing some testing with a 32-bit TIF image with an embedded Rec2020 colorspace. When I convert my image using the commands below to create a JXL and then bring it back to TIF, the image has been significantly degraded. I'm doing a double conversion to help confirm that things are working properly, as well as to test some image formats which I cannot validate in Photoshop (ie, if it comes back the same then I know the export is good even if I cannot view it currently).
What I see is that "converted.hdr" has changed from my Rec2020 embedded color space to an sRGB colorspace. It does show HDR data, but with substantial loss of data (very crude highlights and other tonal shifts).
The "reversedToConfirm.tif" is further degraded and has no embedded profile at all.
What commands should be used to keep the exact same colorspace and pixels when converting from HDR to TIF and back?
Note: I am using ImageMagick 7.1.0-45 Q16-HDRI x64 e32676e:20220731
Beta Was this translation helpful? Give feedback.
All reactions