Gamma values in png, dpx and psd

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ggarra13
Posts: 30
Joined: 2015-04-17T14:08:07-07:00
Authentication code: 6789

Gamma values in png, dpx and psd

Post by ggarra13 »

I have a bunch of png images taken from a web page about gamma with different gammas. My C code opens them and reads their gamma with MagickGetImageGamma() and they are reported correctly. The images display identical regardless of gamma thanks to my opengl code compensating for the image gamma. That's as it should be as I reproduce the results from a web browser.
Now, my problem is that I have other png, psd and dpx images that should not have a gamma, but report to have a gamma of 0.4545. When I load them, they are shown dark. If gamma is set to 1.0, they show fine. If I use display to show them no gamma correction takes place and these images display as if gamma was 1.0.
I am wondering if someone can explain how gamma works in ImageMagick. I read that in a png if there is some SRGB chunk, the gamma is disregarded.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gamma values in png, dpx and psd

Post by fmw42 »

I believe that IM assumes sRGB (gamma=0.4545) for most images unless they are of a format that is expected to be linear RGB (gamma=1). But the IM and PNG developers can explain the workings of IM gamma better than I.

Also you did not report your IM version and platform. See viewtopic.php?f=4&t=21269 about IM versions and sRGB and RGB being swapped.
ggarra13
Posts: 30
Joined: 2015-04-17T14:08:07-07:00
Authentication code: 6789

Re: Gamma values in png, dpx and psd

Post by ggarra13 »

I am using ImageMagick 6.9.1-1 on Linux compiled from source with HDRI support and no OpenEXR support.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Gamma values in png, dpx and psd

Post by snibgo »

IM's convert and identify assume images are sRGB, unless told otherwise by file metadata or a comand.

By contrast, IM's display shows the image in "raw" form, ignoring metadata about gamma or profiles.
snibgo's IM pages: im.snibgo.com
ggarra13
Posts: 30
Joined: 2015-04-17T14:08:07-07:00
Authentication code: 6789

Re: Gamma values in png, dpx and psd

Post by ggarra13 »

I read the gamma of 0.4545 as default and it is awful. How can one distinguish an image that is really gamma 0.4545 from one that ImageMagick guesses that it is? I am wondering how to do this from the C api.
Surely a DPX file that is log encoded should not carry a gamma of 0.4545.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gamma values in png, dpx and psd

Post by fmw42 »

If the format does not support a gamma value in the meta data, then IM assumes it to be sRGB gamma=0.4545. I do not know if IM can distinguish that the DPX file is log encoded, unless that is either in the meta data or is always the case for DPX. However, I know little about DPX and will defer to the IM developers.

see http://www.imagemagick.org/script/motion-picture.php for more information about IM and DPX. But according to that, log format is not required.

I see no field that says if it is log encoded. But there is a field dpx:television.gamma. However, I do not know if that is pertinent to the image gamma value. IM allows you to set the gamma or film gamma, but I do not see a field in the meta data for either. So it looks like it is not stored there.

An IM developer will need to comment on your issues.
Post Reply