using (MagickImage image = new MagickImage(inputFile))
{
image.Format = MagickFormat.Jpg;
image.AddProfile(ColorProfile.SRGB);
image.TransformColorSpace(ColorProfile.SRGB, ColorProfile.USWebCoatedSWOP);
MagickColor srcColor = new ColorCMYK(74, 68, 66, 90);
MagickColor destColor = new ColorCMYK(100, 0, 0, 0);
image.ColorFuzz = new Percentage(30);
image.Opaque(srcColor, destColor);
// Save image
image.Write(outputFile);
}
Photoshop tells me the RGB's black is now 74, 68, 66, 90 CMYK so I try to convert to something like 100% cyan but the code gives me CMYK of 0, 100, 100, 0. Changing the new color's CMYK values gives me completely different colors in Photoshop.
What am I doing wrong?
This is just a guess since I do not use any API, only the command line. But you have not changed the colorspace of the image except via profiles, so your image is still using RGB colors as pixels and IM converts your CMYK colors back to RGB. Then lets the profiles do the conversion for display. Try changing the colorspace of the data to CMYK.
Just another additional guess, but your input colorspace is sRGB since PNG does not support CMYK. So why specify the input color in CMYK. Perhaps specify it as RGB. cyan is rgb(0,255,255) or rgb(0,100%,100%).
Snibgo has a good point about color ranges (units) as raw values 0-255 vs percent 0-100.
MagickColor destColor = new ColorCMYK(255, 0, 0, 0);
I still don't get a Cyan only color. It comes out red so I think there is something going on where colors are still being interpreted as RGB instead of CMYK but I don't know what.
I need the image to be "print-ready" using CMYK. Printers don't like RGB. RGB is for screen display only.
dlemstra just told you how to use ColorCMYK. The range of values you need to use depend upon your IM Q level for your compile. Standard compile is Q16 which means you need to use values in the range 0-65535. So just scale percent value by 65535/100 or scale values in the range 0-255 by 65536/255.
Thanks for all the suggestions but there might be something wrong with the Magick.Net implementation.
Even when using Quantum values, if I use ColorCMYK(255, 0, 0, 0) my color comes out red. If I use ColorCMYK(0, 255, 0, 0) my color comes out green. So ColorCMYK() seems to be setting RGB values behind the scene. I've even tried this on files I know are CMYK already.
I haven't tried the command line version but when I get around to it, I'll report back.
pti wrote:Thanks for all the suggestions but there might be something wrong with the Magick.Net implementation.
Even when using Quantum values, if I use ColorCMYK(255, 0, 0, 0) my color comes out red. If I use ColorCMYK(0, 255, 0, 0) my color comes out green. So ColorCMYK() seems to be setting RGB values behind the scene. I've even tried this on files I know are CMYK already.
I haven't tried the command line version but when I get around to it, I'll report back.
Are you on Q8 IM compile? If not and for example are on Q16 compile, then quantumrange is 0-65535. Check your Q level from