Re: RGB colorspace question

Bob Friesenhahn <[email protected]> Wed, 10 Jan 2024 15:50:03 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Tue, 9 Jan 2024, Michael Orlitzky wrote:
>
> Is there some other way to get the linear RGB pixel values, that would
> work the same in both GM and IM? Perl and anything POSIX should also
> be fair game. I think the difficulty lies in figuring out the color
> space of the source.

The notion of "sRGB" is interesting, because it describes the behavior 
of CRT monitor's from the '80s and early '90s.  It has been a long 
time since any of us has used anything like that. In fact, many modern 
LCD monitors intentionally do not present sRGB or they may have a 
special sRGB mode.

True sRGB is not entirely based on a smooth curve.  See 
https://en.wikipedia.org/wiki/SRGB for details.

The primary element of converting from sRGB to Linear is a gamma 
transformation.

Perhaps this will get you mostly there (change to ".txt" extension for 
text)

   gm convert sRGB.webp -gamma 2.2 linear_rgb.webp

and back

   gm convert linear_rgb.webp -gamma 0.45454545 sRGB.webp

but it is best to use ICC color profiles with the -profile option

   gm convert sRGB.webp -profile sRGB.icc -profile linear.icc linear_rgb.webp

but then it is up to you to find the correct profiles to use.  If 
there is a profile which is a good match for the monitor, then that 
should be used instead of "sRGB.icc".

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt