Page 1 of 1

PixelSetColor problem with CMYK images

Posted: 2009-09-30T07:51:29-07:00
by sithney
Hello,

I have a problem where PixelSetColor seems to set the wrong color when using CMYK images.
When using RGB values as rgb(r,g,b) the colors seem to either be CMYK values, or not work at all.
In the sample program shown, rgb(255,0,0) produces Cyan text.
Any help with this would be appreciated.

Here is my sample code:

#include "wand/MagickWand.h"
int main() {
char *file = "cmyk.jpg"; /* this must be a CMYK file */
char *output_file = "out.pdf";
MagickWand *image = NewMagickWand();
DrawingWand *draw = NewDrawingWand();
PixelWand *pixel = NewPixelWand();

MagickReadImage(image, file);
PixelSetColor(pixel, "rgb(255,0,0)");
DrawSetFillColor(draw, pixel);
DrawAnnotation(draw, 100, 100, "hello");
MagickDrawImage(image, draw);
MagickWriteImage(image, output_file);
return 0;
}

Re: PixelSetColor problem with CMYK images

Posted: 2009-09-30T09:23:58-07:00
by magick
Most ImageMagick algorithms have direct support for CMYK and CMYKA, however, the drawing engine is based on the SVG specification which does not include support for CMYK. Therefore, for drawing you must first convert your image to RGB, draw on it, and then convert from RGB back to CMYK.

Re: PixelSetColor problem with CMYK images

Posted: 2012-01-26T17:11:19-07:00
by rohitkrishna
Maay be you can use cmyk(100,100,100,10) instead of r,g,b(0,0,255)

Re: PixelSetColor problem with CMYK images

Posted: 2012-01-26T17:53:21-07:00
by fmw42
rohitkrishna wrote:Maay be you can use cmyk(100,100,100,10) instead of r,g,b(0,0,255)

The limitation is with the image colorspace and not the color value. So I don't think that will help as -draw only works with images in RGB colorspace. So IM will either convert your cmyk color value to its rgb equivalent or -draw will object to the cmyk value supplied or use it as an rgba value. However, I will defer to the IM developers if I am wrong.

Re: PixelSetColor problem with CMYK images

Posted: 2012-01-27T20:31:21-07:00
by anthony
Draw currently just assumes the color and image colorspace is RGB.

Actually it is worse than that as draw it seems to assume linear RGB, while colors are given as sRGB colors. See
http://www.imagemagick.org/Usage/draw/#colorspace

These are all aspects that will be fixed in the early version numbers of IMv7 (still in alpha while I work on the CLI interface)