Is there a direct way using the Magick Core api to convert a colour in one colour space to the equivalent in another. I do not mean an image, I want to change say the background colour that I get as an rgb triplet into the corresponding colour in an images colour space. e.g. I tried drawing a red circle on a cmyk image and it was not red so I need to convert red to red in the image space.
The only way I have thought of is to create a one pixel image and convert that, any other ideas?
I am actually using version 7 but I suspect someone has come across the same problem before.
Alan Hadley
Colour Space Conversion
-
- Posts: 48
- Joined: 2010-03-31T12:17:55-07:00
- Authentication code: 8675308
Re: Colour Space Conversion
ImageMagick includes a number of pixel colorspace transforms, look for them in magick/gem.h and magick/colorspace-private.h.
-
- Posts: 48
- Joined: 2010-03-31T12:17:55-07:00
- Authentication code: 8675308
Re: Colour Space Conversion
Thank's but I was looking for a general method, I have used the one pixel method mentioned above and it works OK for most colour spaces, the two that fail in a major way are GREY and YCC, LMS shows a slight change. But as I know nothing about colour space things in general, just following my nose, I do not know the significance of this. I can now create blank images in almost any colour space using a colour picker dialog to set the colour. I now need to use the same method for all of the other functions that need a colour e.g. Tint, Gradient etc., but that should be simple now that I have a method.
Alan Hadley
Alan Hadley
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Colour Space Conversion
Perhaps if you explain what you want the color for..
In Imagemagick as the background color setting? just as text output?
In Imagemagick as the background color setting? just as text output?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 48
- Joined: 2010-03-31T12:17:55-07:00
- Authentication code: 8675308
Re: Colour Space Conversion
To pass into various functions. For if I want to draw a red circle I could use something like "fill #ff000000 circle 50,50 10,50" in the sRGB colour space it works fine but in any other the #ff000000 needs to be something else. I realize that I can't use named colours in a Draw string because there is no practical way of transforming them. My raw data is three/four/five colour components which I pass to a string processing function to build the #ff000000 so all I need is a way of changing the three components so that I they match the colourspace of the target image.
The above example is not the only one any function which takes a PixelInfo structure or an equivalent in an earlier version of IM will need the colour in the correct colour space.
Alan Hadley
The above example is not the only one any function which takes a PixelInfo structure or an equivalent in an earlier version of IM will need the colour in the correct colour space.
Alan Hadley
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Colour Space Conversion
It is planned to eventually have the color name convert as appropriately to match the colorspace.
As such if Draw draws in linear-RGB colorspace (which is what it should draw in to get anti-aliasing right) then a fill 'named-color' will be converted to linear-RGB for that purpose. This is why color storage now has some colorspace attached to the color.
I just don't think this step of the process has been done as yet.
The other way if have a single pixel image and convert that, then extract the color values.
I do not believe any API (except MagickCore) has access to the color conversion routines (in gem.c)
As such if Draw draws in linear-RGB colorspace (which is what it should draw in to get anti-aliasing right) then a fill 'named-color' will be converted to linear-RGB for that purpose. This is why color storage now has some colorspace attached to the color.
I just don't think this step of the process has been done as yet.
The other way if have a single pixel image and convert that, then extract the color values.
I do not believe any API (except MagickCore) has access to the color conversion routines (in gem.c)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/