sRGB to RGB colorspace / profile not working?

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: sRGB to RGB colorspace / profile not working?

Post by snibgo »

Modern web (and other) software assumes that colour images are encoded as (non-linear) sRGB rather than (linear) RGB, unless told otherwise. Even if told otherwise by gamma flag etc in PNG files, much software ignores this and treats it as sRGB.

For this reason, I think using RGB for web applications is unwise. If the user specifies colours in RGB, these can easily be converted to sRGB, or vice versa, eg:

Code: Select all

F:\web\im>%IM%convert xc:rgb(239,152,50) -set colorspace RGB -colorspace sRGB -d
epth 8 txt:
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (248,203,122)  #F8CB7A  srgb(248,203,122)
snibgo's IM pages: im.snibgo.com
mackermedia
Posts: 15
Joined: 2013-01-25T12:59:01-07:00
Authentication code: 6789

Re: sRGB to RGB colorspace / profile not working?

Post by mackermedia »

I tried the 3 examples that you posted at the bottom, and they all look the same. I did notice an error output while running the command:

convert: ColorspaceColorProfileMismatch `icc' @ error/profile.c/ProfileImage/588.

. The resultant images look like: https://dl.dropboxusercontent.com/spa/l ... x93nat.png

Am I missing something obvious? Is it possible the files I found are bad? Could you share the ones you are using?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sRGB to RGB colorspace / profile not working?

Post by fmw42 »

snibgo wrote:Modern web (and other) software assumes that colour images are encoded as (non-linear) sRGB rather than (linear) RGB, unless told otherwise. Even if told otherwise by gamma flag etc in PNG files, much software ignores this and treats it as sRGB.

For this reason, I think using RGB for web applications is unwise. If the user specifies colours in RGB, these can easily be converted to sRGB, or vice versa, eg:

Code: Select all

F:\web\im>%IM%convert xc:rgb(239,152,50) -set colorspace RGB -colorspace sRGB -d
epth 8 txt:
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (248,203,122)  #F8CB7A  srgb(248,203,122)
I would agree with snibgo, also. Linear RGB is not a good colorspace to which to save as most format and viewers cannot handle it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sRGB to RGB colorspace / profile not working?

Post by fmw42 »

mackermedia wrote:I tried the 3 examples that you posted at the bottom, and they all look the same. I did notice an error output while running the command:

convert: ColorspaceColorProfileMismatch `icc' @ error/profile.c/ProfileImage/588.

. The resultant images look like: https://dl.dropboxusercontent.com/spa/l ... x93nat.png

Am I missing something obvious? Is it possible the files I found are bad? Could you share the ones you are using?
What version of IM and what platform and what viewer. I used the IM display (show:) in unix on my Mac and they can clearly be seen to differ. But it takes a good viewer to properly handle profiles.

I do not know why you got an error unless you do not have the exact same profiles and you will of course need to put them on your system in a different location that I did and reference your path to them
mackermedia
Posts: 15
Joined: 2013-01-25T12:59:01-07:00
Authentication code: 6789

Re: sRGB to RGB colorspace / profile not working?

Post by mackermedia »

Can you please give me an example of a specific display command that you used to view these? I'm using Preview in OSX as the Viewer. I'm also using the OSX Color Utility to determine sRGB vs Generic RGB values.

Also, I wasn't able to get the command to work to convert rgb values and srgb values (convert xc:rgb(239,152,50) -set colorspace RGB -colorspace sRGB -d
epth 8 txt:). It's failing on the last part of the command which ends in `txt:`
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sRGB to RGB colorspace / profile not working?

Post by fmw42 »

there is no txt: in my commands
fmw42 wrote:convert -size 100x100 xc:"rgb(239,152,59)" -depth 8 orange_srgb.tif

convert -size 100x100 xc:"icc-color(rgb,0.937,0.596,0.231)" -profile /Users/fred/images/Profiles/sRGB.icc -profile /Users/fred/images/Profiles/GenericRGBProfile.icc -depth 8 orange_rgb.tif

convert -size 100x100 xc:"rgb(239,152,59)" -profile /Users/fred/images/Profiles/sRGB.icc -profile /Users/fred/images/Profiles/GenericRGBProfile.icc -depth 8 orange_rgb2.tif

convert orange_srgb.tif show:
convert orange_rgb.tif show:
convert orange_rgb2.tif show:
the

convert image show:

does the display in IM.

Or to compare them in a flickering display, just do

animate -delay 50 orange_srgb.tif orange_rgb.tif

P.S. If you open them both up in Preview in the same window and use the arrow keys to alternate between the two images you can see there is a slight difference in darkness of the color. The linear RGB will be darker. It seems to be a bit more obvious using animate.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: sRGB to RGB colorspace / profile not working?

Post by snibgo »

That was my command that ended in "txt:". Sorry, the cut-paste put a new line in it.

Code: Select all

[code]F:\web\im>%IM%convert xc:rgb(239,152,50) -set colorspace RGB -colorspace sRGB -depth 8 txt:
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (248,203,122)  #F8CB7A  srgb(248,203,122)
[/code]
The command is just:

Code: Select all

convert xc:rgb(239,152,50) -set colorspace RGB -colorspace sRGB -depth 8 txt:
snibgo's IM pages: im.snibgo.com
Post Reply