From sRGB to CMYK and gamma?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
This is perl, is it? I don't know perl, so don't know exactly what your code is doing.
However, I note that you need the equivalent of the command-line options "-colorspace RGB" and "-colorspace sRGB". These are very different to the options "-set colorspace RGB" and "-set colorspace sRGB", and perhaps your code is doing "set".
However, I note that you need the equivalent of the command-line options "-colorspace RGB" and "-colorspace sRGB". These are very different to the options "-set colorspace RGB" and "-set colorspace sRGB", and perhaps your code is doing "set".
snibgo's IM pages: im.snibgo.com
Re: From sRGB to CMYK and gamma?
Translated into command line, I'm doing this:snibgo wrote:This is perl, is it? I don't know perl, so don't know exactly what your code is doing.
However, I note that you need the equivalent of the command-line options "-colorspace RGB" and "-colorspace sRGB". These are very different to the options "-set colorspace RGB" and "-set colorspace sRGB", and perhaps your code is doing "set".
Code: Select all
convert input.jpg \
-density 600 -depth 16 \
-colorspace RGB \
-filter Lanczos -resize XXXxYYY \
-crop XXXxYYY \
-some -more -operations \
-colorspace sRGB \
output.png
Re: From sRGB to CMYK and gamma?
If the images look fine on your monitor but print too dark that's most likely a hardware (monitor) calibration issue.
Re: From sRGB to CMYK and gamma?
It is much darker than the original photo on the monitor, too. So the problem must be somewhere in the processing.holden wrote:If the images look fine on your monitor but print too dark that's most likely a hardware (monitor) calibration issue.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
IM v6.7.8 is an old version, so an upgrade might help.
If you put up your image and full command, someone can test on more recent versions.
If you can't put up the image, at least do a "identify -verbose" and paste the results here between [ code ] and [ /code ].
If you put up your image and full command, someone can test on more recent versions.
If you can't put up the image, at least do a "identify -verbose" and paste the results here between [ code ] and [ /code ].
snibgo's IM pages: im.snibgo.com
Re: From sRGB to CMYK and gamma?
The problem is neither an old version nor a broken image. Here's one recipe to get the colorspace handling wrong:snibgo wrote:IM v6.7.8 is an old version, so an upgrade might help.
If you put up your image and full command, someone can test on more recent versions.
If you can't put up the image, at least do a "identify -verbose" and paste the results here between [ code ] and [ /code ].
Code: Select all
convert Fotos/DSC_0304.JPG \
-density 600 -depth 16 \
-colorspace RGB \
-filter Lanczos -resize 600x400 \
\( -size 640x440 xc:grey \) \
+swap \
-gravity center \
-compose Over -composite \
-colorspace sRGB \
output.png
display output.png
The fix is here would be:
Code: Select all
convert Fotos/DSC_0304.JPG \
-density 600 -depth 16 \
-colorspace RGB \
-filter Lanczos -resize 600x400 \
\( -size 640x440 xc:grey \) \
-gravity center \
-compose DstOver -composite \
-colorspace sRGB \
output.png
display output.png
To finally get it right, we need this:
Code: Select all
convert Fotos/DSC_0304.JPG \
-density 600 -depth 16 \
-colorspace RGB \
-filter Lanczos -resize 600x400 \
\( -size 640x440 xc:grey -colorspace RGB \) \
+swap \
-gravity center \
-compose Over -composite \
-colorspace sRGB \
output.png
display output.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
That's it; you've got it. (Beware that default colorspaces for gray images changed in 6.7.9, then again in 6.8.5.)
"-composite" makes one image from two, and the metadata is taken from the first. But I don't know how it handles the situation of the images being in different colorspaces. I think it's best to explicitly make them the same.
"-composite" makes one image from two, and the metadata is taken from the first. But I don't know how it handles the situation of the images being in different colorspaces. I think it's best to explicitly make them the same.
snibgo's IM pages: im.snibgo.com
Re: From sRGB to CMYK and gamma?
Not really. There are still lots of unanswered questions. All this is very confusing, and very badly documented AFAICS.snibgo wrote:That's it; you've got it.
What is when the original image has an attached profile? In this case the -colorspace settings seem to be ignored sometimes, but are still attached to the metadata. And how is one supposed to force linear RGB colorspace when a profile is attached? You need linear colorspace to do manipulations, don't you?
An other example: Please take a look at your great example of the chrome effect you posted a couple of days ago. In what colorspace is the result? How to force it to RGB if you want to combine it with an image? Simply using the -colorspace setting will shift colors and most probably destroy the chrome effect.
Can you give some more details on that?(Beware that default colorspaces for gray images changed in 6.7.9, then again in 6.8.5.)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: From sRGB to CMYK and gamma?
see viewtopic.php?f=4&t=21269Can you give some more details on that?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
It depends. I do most of my work, including resizeing, in sRGB. I do colour-balancing (of raw photos) in linear RGB. I do some processing in CIELab.joew wrote:You need linear colorspace to do manipulations, don't you?
When I have an image that has been converted to a profile, I generally convert it to sRGB.
Most manipulations will work in RGB or sRGB, with or without profiles. But when working with multiple images, it's best that they are are all the same. For my purposes, sRGB generally works best.
Most of the IM Usage pages use cartoon graphics. Perhaps, for those, manipulations work best in RGB (though I'm not convinced). For photos, I think sRGB is better. However, there is rarely much difference.
My metallic/chrome script uses the default colorspace which is sRGB in modern IM versions, so the result is sRGB. If you want to combine it with another image in RGB, just "-colorspace RGB" for both images before the manipulation, and "-colorspace sRGB" afterwards. (This advice is for current IM versions, and might be wrong for your v6.7.8.)
Between roughly 6.7.9 and 6.8.5, IM treated images without colour differently to images with colour, with the unfortunate habit of silently converting grey images from sRGB to RGB. This defeated my rule of thumb that everything should be in the same colourspace, and confused many users. Happily it no longer does this.
snibgo's IM pages: im.snibgo.com
Re: From sRGB to CMYK and gamma?
http://www.imagemagick.org/Usage/resize ... colorspace says resizing should be done in linear RGB.snibgo wrote:It depends. I do most of my work, including resizeing, in sRGB. I do colour-balancing (of raw photos) in linear RGB. I do some processing in CIELab.joew wrote:You need linear colorspace to do manipulations, don't you?
This removes the profile and stores in sRGB? I thought having a profile attached would be the better (thus preferable) method?When I have an image that has been converted to a profile, I generally convert it to sRGB.
Every FAQ and HOWTO I could find on the net states that manipulations should be done in linear color space. Maybe IM does internal conversions if it finds that the image is not yet in linear colorspace, so that manipulations in sRGB work fine because of that invisible conversion? But then, this should be documented clearly.Most manipulations will work in RGB or sRGB, with or without profiles But when working with multiple images, it's best that they are are all the same. For my purposes, sRGB generally works best.
Can I be confident that all three of the following commands:
Code: Select all
convert -size 100x100 xc:somecolor -colorspace sRGB t1.png
convert -colorspace RGB -size 100x100 xc:somecolor -colorspace sRGB t2.png
convert -colorspace sRGB -size 100x100 xc:somecolor -colorspace sRGB t3.png
As stated at the beginning of the thread, I have seen huge differences.Most of the IM Usage pages use cartoon graphics. Perhaps, for those, manipulations work best in RGB (though I'm not convinced). For photos, I think sRGB is better. However, there is rarely much difference.
Yeah. But you use the -gamma option, which brings us back to the very first post in this thread:My metallic/chrome script uses the default colorspace which is sRGB in modern IM versions, so the result is sRGB.
Code: Select all
display: Ignoring incorrect gAMA value .20661 when sRGB is also present `t.png' @ warning/png.c/MagickPNGWarningHandler/1777.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
When I say "I do something", it doesn't mean everyone else should.
And don't forget that what looks best also depends on the quality of the monitor, printer, whatever.
And don't forget that an attached profile means either (a) assigned metadata that has no effect on processing or (b) pixel values have been converted to this other colorspace. If (b), then processing will work differently on the same image that has been converted to different colorspaces. I would find this confusing.
Yes, I'm aware of that. I'm not convinced by the earthspace demonstration. I agree the non-converted image is too dark, but the converted image looks too light (to me). But what matters is what looks right to you (or your client), and these matters are rather subjective. See the Digital Image Processing forum for discussions.joew wrote:http://www.imagemagick.org/Usage/resize ... colorspace says resizing should be done in linear RGB.
And don't forget that what looks best also depends on the quality of the monitor, printer, whatever.
Yes.joew wrote:This removes the profile and stores in sRGB?
Why? Profiles are normally used to specify the colour characteristics of the input device, or to prepare for an output device. I don't want to retain the input profile during processing -- it's of no importance. An output profile is only important after the processing is done.joew wrote:I thought having a profile attached would be the better (thus preferable) method?
And don't forget that an attached profile means either (a) assigned metadata that has no effect on processing or (b) pixel values have been converted to this other colorspace. If (b), then processing will work differently on the same image that has been converted to different colorspaces. I would find this confusing.
They are often blindly repeated from each other. But if it works for them (or you), that's fine.joew wrote:Every FAQ and HOWTO I could find on the net states that manipulations should be done in linear color space.
Current versions of IM do not (thankfully) do any colorspace conversions without being told to do so. As far as I know.joew wrote:Maybe IM does internal conversions if it finds that the image is not yet in linear colorspace, so that manipulations in sRGB work fine because of that invisible conversion?
In current versions, yes. However, note that "-colorspace something" converts an image already in memory; if there is no image (because this is the first operation) it should do nothing. In your examples, "-colorspace sRGB" at the end will also do nothing because the image is already sRGB.joew wrote:Can I be confident that all three of the following commands: ... will give me exact the same image?
Agreed.joew wrote:I think the distinction between "declaring" (this modifies only the metadata) and actually converting from one colorspace to an other is a very important distinction.
Perhaps not, explicitly. Colour concepts are described quite well in http://www.imagemagick.org/Usage/color_basics/, http://www.imagemagick.org/script/color-management.php, etc, but beware that these are somewhat out of date, and greyscale now processes exactly like colour.joew wrote:But I can't find anything in the IM documentation that would explain this distinction.
In that case, use whatever works for you.joew wrote:As stated at the beginning of the thread, I have seen huge differences.
I agree the warning is weird, but you can ignore it. I think gamma is stored in PNG files for historical reasons, as a hint to display software that the image should undergo further gamma correction before being displayed. Most software ignores the setting. If it troubles you, you can eliminate the warning by "-set colorspace sRGB" immediately before the output filename. This resets the gamma setting as appropriate for sRGB, 0.454545.joew wrote:Yeah. But you use the -gamma option, which brings us back to the very first post in this thread: ...
snibgo's IM pages: im.snibgo.com
Re: From sRGB to CMYK and gamma?
As long I don't have a clue by myself, I tend to look what other people dosnibgo wrote:When I say "I do something", it doesn't mean everyone else should.
I find this explanation very imressive and also easy to understand.Yes, I'm aware of that. I'm not convinced by the earthspace demonstration.joew wrote:http://www.imagemagick.org/Usage/resize ... colorspace says resizing should be done in linear RGB.
Ugh. I don't like subjective results at all. If the result looks different to different people, then I can just as well use a deterministic and correct algorithm.But what matters is what looks right to you (or your client), and these matters are rather subjective.
That's why I don't want to rely on what looks good to me. I want to use the correct methods in the first place. I think this way the result will look good if it is output onto a proper device (maybe with profiles used).And don't forget that what looks best also depends on the quality of the monitor, printer, whatever.
This point has a merit. Is using "-colorspace RGB" enough to get rid of the profiles?Yes.joew wrote:This removes the profile and stores in sRGB?Why? Profiles are normally used to specify the colour characteristics of the input device, or to prepare for an output device. I don't want to retain the input profile during processing -- it's of no importance. An output profile is only important after the processing is done.joew wrote:I thought having a profile attached would be the better (thus preferable) method?
And don't forget that an attached profile means either (a) assigned metadata that has no effect on processing or (b) pixel values have been converted to this other colorspace. If (b), then processing will work differently on the same image that has been converted to different colorspaces. I would find this confusing.
joew wrote:Can I be confident that all three of the following commands: ... will give me exact the same image?
Code: Select all
convert -set colorspace RGB -colorspace RGB -size 100x100 xc:#bebebe -colorspace sRGB 1.png
convert -set colorspace RGB -colorspace sRGB -size 100x100 xc:#bebebe -colorspace sRGB 2.png
convert -set colorspace sRGB -colorspace RGB -size 100x100 xc:#bebebe -colorspace sRGB 3.png
convert -set colorspace sRGB -colorspace sRGB -size 100x100 xc:#bebebe -colorspace sRGB 4.png
3.png and 4.png result in #bebebe
I'd have expected that 1.png is identical to 3.png while 2.png is identical to 4.png.
Since I explicitly set the colorspace before creating any drawings, changes in defaults should not have any influence...
Whatever the defaults are in this version of IM, 1 and 3 should be in RGB at the time when the color is drawn. 2 and 4 should be in sRGB for the same reason. Why do I get the opposite of the expected result? Since my expectation don't match the results, there must still be some important points that I am missing
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: From sRGB to CMYK and gamma?
It depends upon what version of IM you are using. I don't recall you ever specified. See snibgo's comment earlier about changes in IM colorspace handling or see viewtopic.php?f=4&t=21269. That affects whether you need to use -set colorspace RGB to avoid converting to linear RGB or not.I'd have expected that 1.png is identical to 3.png while 2.png is identical to 4.png.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: From sRGB to CMYK and gamma?
Thanks for the link. I'll read it.
Just for fun, let's be objective. Take the earthlights image (http://eoimages.gsfc.nasa.gov/ve//1438/ ... s_4800.tif). Find the mean intensity. Resize with different colorspace conversions, and find the mean intensity of each. This is an objective test of lightness.
As expected, the second and third are the same (they both stay in sRGB).
Which resize is objectively "best"?
This converts it to a sRGB profile, then removes the profile. I should say that opinions differ, but this works for me.
1,2,3,4.png: I get the same results as you, using IM 6.8.6-0. This seems to show that "-set colorspace RGB" has an effect even when placed before the image. But I don't think it's advisable. And putting "-colorspace anything" before any image is both syntactically wrong and does weird things. I'd prefer that IM threw an error.
Two correct syntaxes are:
That's fair enough. I mostly make images for people, not machines, so what they look like is (for me) of prime importance.joew wrote:Ugh. I don't like subjective results at all. If the result looks different to different people, then I can just as well use a deterministic and correct algorithm.
Just for fun, let's be objective. Take the earthlights image (http://eoimages.gsfc.nasa.gov/ve//1438/ ... s_4800.tif). Find the mean intensity. Resize with different colorspace conversions, and find the mean intensity of each. This is an objective test of lightness.
Code: Select all
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert earth_lights_4800.tif -colorspace Gray -format "%[fx:mean]" info:
0.0507808
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert earth_lights_4800.tif -colorspace Gray -resize 500 -format "%[fx:mean]" info:
0.050977
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert earth_lights_4800.tif -colorspace Gray -colorspace sRGB -resize 500 -colorspace sRGB -format "%[fx:mean]" info:
0.050977
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert earth_lights_4800.tif -colorspace Gray -colorspace RGB -resize 500 -colorspace sRGB -format "%[fx:mean]" info:
0.064399
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert earth_lights_4800.tif -colorspace Gray -colorspace Lab -resize 500 -colorspace sRGB -format "%[fx:mean]" info:
0.0504707
Which resize is objectively "best"?
No. It has no effect at all on profiles. If a file has an embedded profile, I think the best action isjoew wrote:Is using "-colorspace RGB" enough to get rid of the profiles?
Code: Select all
-profile sRGB.icc +profile "*"
1,2,3,4.png: I get the same results as you, using IM 6.8.6-0. This seems to show that "-set colorspace RGB" has an effect even when placed before the image. But I don't think it's advisable. And putting "-colorspace anything" before any image is both syntactically wrong and does weird things. I'd prefer that IM threw an error.
Two correct syntaxes are:
Code: Select all
convert -size 100x100 xc:#bebebe -set colorspace RGB -colorspace sRGB 5.png
convert -size 100x100 xc:#bebebe -set colorspace sRGB -colorspace sRGB 6.png
snibgo's IM pages: im.snibgo.com