[Gimp-developer] Gimp and OpenEXR and Darktable



Darktable can save OpenEXR files and Gimp can open them. Which theoretically means that an interpolated raw file can be processed at 32-bit floating point all the way from opening the raw file, until the final image is exported from Gimp.

However, Gimp acts in an unexpected way.

When Gimp opens an OpenEXR file, it applies an inverse sRGB tone response curve correction. If the user hasn't chosen another RGB color space, then Gimp also automatically assigns the sRGB built-in color space. The inverse sRGB TRC means the image looks correct if, and only if, the OpenEXR file is in a necessarily linear gamma version of the sRGB color space.

This is wrong behavior for an OpenEXR file.

OpenEXR is supposed to be ***linear***. So applying an inverse sRGB tone response curve correct makes no sense at all, unless you assume that the only color space any OpenEXR image will ever be in, is the sRGB color space. But OpenEXR files can be in any color space, as long as it's a linear gamma color space.

So the Gimp code leaves out in the cold anyone who tries to open OpenEXR files that aren't also sRGB color space files. Personally, the only thing I ever use sRGB for is as an output space for posting images to the web; I suspect many people who shoot raw have a similar workflow.

Gimp's automatically applied inverse sRGB tone response curve correction means that if the user assigns an actual linear gamma sRGB profile to the OpenEXR image), the image will look way too light.

If the OpenEXR image is really supposed to be ProPhoto or ACES or a camera input profile or anything other than sRGB, in Gimp the colors will look very, very wrong, and especially after the user assigns what in reality actually is the right (linear gamma) ICC profile, because the inverse sRGB TRC correction means that as soon as a linear gamma ICC profile is assigned, the tonality is completely wrong.

Gimp doesn't do this when opening a linear gamma tiff or png. It only does it for file formats that can only be linear. So the behavior is inconsistent. If I make three files, one tiff, one png, one OpenEXR, all in the same linear gamma color space, Gimp will open the png and tiff correctly, but not the OpenEXR.

I have two versions of babl/gegl/gimp from git installed on my computer, in different prefixes. I keep them both updated and run both of them regularly. One version is completely unmodified. The other version (the one I use for my own image editing) has two major departures from the unmodified version: All the back-and-forth Babl conversions between linear and regular srgb tone response curve are completely disabled. And I reverted the EXR handling to before the most recent changes so I can open and also export EXR files.

In my modified babl/gegl/gimp, OpenEXR files open as true linear gamma files, such that applying the correct linear gamma ICC profile makes the colors look right. That's because those sRGB-TRC-to-Linear Babl conversions are all disabled.

I realize that proper handling of OpenEXR is just one of many enhancements many people want for Gimp to have. After looking over OpenEXR code from various programs that read and write OpenEXR files, and reading through some of the OpenEXR documentation, I also realize that coding up proper OpenEXR support is not a simple undertaking. For one thing, color space information is carried in a metadata tag that Exiv2 probably can't read.

But one simple change in the default Gimp code will make it possible for people to open OpenEXR files right now, the right way (that is, open the file and assign a linear gamma version of whatever ICC profile matches the color space the file is actually in):

Open this file: https://git.gnome.org/browse/gimp/tree/plug-ins/file-exr/file-exr.c and change line 204 to read "image_precision = GIMP_PRECISION_FLOAT_GAMMA; /* GIMP_PRECISION_FLOAT_LINEAR; */".

There are several other lines in that file that deal with different formats for OpenEXR files, for which similar changes would be needed. But the one change will take care of 32-bit floating point RGB OpenEXR files, which is the kind of OpenEXR file that Darktable saves when you interpolate a raw file and ask for OpenEXR output.

The user still won't be able to export OpenEXR files to disk, but at least s/he can open them. It wouldn't be full and proper OpenEXR support, but it would make OpenEXR useable right now for more than just those people who only use the sRGB color space.

If this change is made, the user must actually have a linear gamma version of the color space the OpenEXR file is in. Linear gamma versions of sRGB are packaged with many image editing programs.

This page: http://ninedegreesbelow.com/gimpgit/gimp-openexr.html has pictures showing the problem. There are also download links for several linear gamma ICC profiles and some sample OpenEXR files in different color spaces. I could make a complete set of linear gamma working space profiles available, if anyone is interested.

Elle

--
Elle Stone
http://ninedegreesbelow.com
Articles on color management and open source photography


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]