[SOLVED] Magick++ ColorCMYK

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

[SOLVED] Magick++ ColorCMYK

Post by rodlie » 2018-12-13T01:47:54-07:00

Hi,

Would it be possible to get support for ColorCMYK in Magick++? I need to draw CMYK colors on CMYK image and can't find any CMYK color support in Magick++.

Regards
Last edited by rodlie on 2018-12-25T23:00:52-07:00, edited 1 time in total.

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-13T04:47:16-07:00

So, I'm able to get the correct(-ish) color by just adding cyan=>red etc, but for some reason the color/brush is transparent.

Image

Edit:
I'm running 6.9.10-16 Q16HDRI.

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ ColorCMYK

Post by fmw42 » 2018-12-13T09:42:03-07:00

What color brush? ImageMagick is command line driven for the most part.

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-13T11:21:45-07:00

I setup a brush then draw (DrawLine with strokeColor etc). Works fine on RGB, but not CMYK. (as seen on the image above). I guess ColorCMYK support in Magick++ would fix this? Or are there any workaround for this?

Code: Select all

image.strokeAntiAlias(...);
image.strokeLineCap(...);
image.strokeLineJoin(...);
image.strokeWidth(...);
image.strokeColor(...);
image.draw(...);

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ ColorCMYK

Post by fmw42 » 2018-12-13T13:54:53-07:00

ImageMagick works best in RGB colors. I am not sure you can draw properly in CMYK. But I will defer to the IM developers to correct me.

snibgo
Posts: 11796
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Magick++ ColorCMYK

Post by snibgo » 2018-12-13T14:19:53-07:00

IM colour names are just shortcuts to particular pixel numbers, eg "red" is "#f00". But in CMY, "#f00" is really cyan.

So I suggest you use numbers, not names, when using CMYK.
snibgo's IM pages: im.snibgo.com

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-14T07:55:24-07:00

I always use color numbers in IM (so I don't need to reference colors.xml).

My problem is that it seems IM always will draw in RGB, but on an CMYK image the colors are "inverted" and transparent. I can fix the color but not the transparency.

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ ColorCMYK

Post by fmw42 » 2018-12-14T10:43:23-07:00

rodlie wrote:
2018-12-14T07:55:24-07:00
My problem is that it seems IM always will draw in RGB, but on an CMYK image the colors are "inverted" and transparent. I can fix the color but not the transparency.
That is what I mentioned earlier. I believe that -draw only works in RGB.

CMYK color specifications I believe are just converted to RGB values before being used.

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-14T11:19:11-07:00

Yeah, that's what I though. But using RGB colors still produces the transparency effect when drawing on CMYK, is there a way to workaround that issue? I would prefer not to convert the image to RGB before drawing and then converting back to CMYK, that will just kill performance (I could of course find ways around that as-well, but I just want to draw some pixels on an image just before print).

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ ColorCMYK

Post by fmw42 » 2018-12-14T13:54:00-07:00

You should convert your CMYK image to RGB, then draw on it, then convert back to CMYK if you need it in that colorspace. Conversion with profiles does a better job than just -colorspace.

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-14T14:20:37-07:00

Yeah, I know, but as I said earlier I don't want to do that if possible. Why is drawing anything on CMYK (except for black) transparent? is there something I need to set, or know about? I'm also open to modifying the (IM) source just to get this (no transparency) working. Any pointers to the problem is welcome :)

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-14T14:40:06-07:00

Found the issue. I'm compositing the drawn image as an "layer" on top of an transparent image (CMYKA) and the composite (Over) seems to add the transparency (on the brush strokes).

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: Magick++ ColorCMYK

Post by rodlie » 2018-12-15T18:32:41-07:00

I was a bit quick on that one. I still get transparent color/stroke when I draw on the image and do nothing else. So draw (rgb) on CMYK image will produce transparent color/stroke on any color.

rodlie
Posts: 23
Joined: 2018-12-13T01:41:06-07:00
Authentication code: 1152

Re: [SOLVED] Magick++ ColorCMYK

Post by rodlie » 2018-12-25T23:02:09-07:00

I have finally ported the app to IM7 and to my surprise it now works, no more transparent strokes :)

Post Reply