Wrong colors from opening and exporting non-sRGB tiffs and pngs
This bug report is for GIMP-2.99 compiled on Gentoo (and also on Debian), and probably also for GIMP-2.10 - edit: No, my apologies, actually it doesn't seem to be a problem on GIMP-2.10.
Second edit: GIMP-2.99 can't open any linear gamma tiff saved to disk by any software or version of GIMP other than GIMP-2.99. So ignore all references to "exported by a raw processor.
It doesn't matter how the tiff was produced. GIMP-2.99 can't properly import linear gamma tiffs in color spaces other than linear sRGB. Nor can it properly export linear gamma tiffs in color spaces other than linear sRGB.
It gets worse: If a linear sRGB tiff is opened from disk with GIMP-2.99 and converted to a non-sRGB linear color space, and then exported, and then reopened with GIMP-2.99 and with GIMP-2.10, the two versions of GIMP report different channel values for what should be the same color. GIMP-2.99 corrupts the image in the process of converting from linear sRGB to some other linear gamma RGB color space.
I've only tested linear gamma images at 32f linear precision, and also 16-bit linear gamma tiffs and pngs.
Resetting babl/GEGL/GIMP to just before the babl space invasion fixes the problems.
############## These following "Steps to reproduce" aren't necessary though they do work to reproduce the problem. A raw processor-exported tiff isn't required. Any 32f linear tiff not in the linear sRGB color space, regardless of how generated, will show the problems.###############
Steps to reproduce:
Open a camera raw file using darktable or PhotoFlow, and probably most/all other raw processors. Open the raw file directly from disk using the raw processor itself, not via using one of the GIMP raw processor plug-ins.
Export the processed raw file to disk as a 32f tiff in the regular (gamma=2.2 TRC) ClayRGB (AdobeRGB1998-compatible) color space. I haven't checked results of exporting using other file formats or at other precisions.
Start GIMP and make sure that in Preferences the option is set to not promote to 32f linear precision, and to keep the embedded ICC profile. Then open the tiff exported to disk by the raw processor. The colors are wrong. In fact the colors look like GIMP has assigned the GIMP built-in sRGB profile to the just-opened regular ClayRGB (AdobeRGB1998) tiff, even though I elected to keep the embedded ClayRGB ICC profile:
The weird thing is that "Image/Properties" shows the correct ICC profile:
Assigning various other ICC profiles, with various TRCs, does result in tonality changes, but not color changes - the image looks slightly darker, or more or less washed out, but always with greens that are too yellow. So it looks like GIMP is making and then assigning new profiles by pairing the sRGB primaries with the TRC of the assigned ICC profile. I'm guessing the profile that GIMP "assigns" on opening the tiff might actually have the sRGB primaries and the gamma=2.2 TRC from the actually embedded ClayRGB profile, instead of the sRGB TRC, but I haven't double-checked - in this case the resulting tonality change would be subtle.
I just tried exporting a TIFF from Darktable in AdobeRGB, but Gimp didn't recognize the profile and I got incorrect colors. Do you want me to test with exporting JPGs as well?
To replicate the problem it's probably necessary that the camera itself be set to save jpegs in the sRGB color space, resulting in DCF metadata that specifies sRGB, or possibly any other combination of embedded DCF information plus an embedded ICC profile, where the embedded profile doesn't match the DCF.
Using exiftool to strip all metadata from the tiff, and then using exiftool to embed the ClayRGB ICC profile in the tiff, and then opening the image using GIMP-2.99, results in proper colors.