Compose CMYK Files Using CompositeImageChannel function

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

Compose CMYK Files Using CompositeImageChannel function

Post by diuming »

Dear Master,

I'm using CompositeImageChannel to compose CMYK files, But black channel always appear "black" no any image in in.
C,M,Y channels are look very well.
.
.
status = CompositeImageChannel(cmykImage, BlackChannel , CopyBlackCompositeOp , srcImage, 0, 0);
.
.
WriteImage(imageInfo, cmykImage);

somebody can help me to figure out , thanks!! :D
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Compose CMYK Files Using CompositeImageChannel function

Post by anthony »

The problem is that it copies channels. A RGB Greyscale image does not contain Black.
As such you get nothing copied!

See...
http://www.imagemagick.org/Usage/bugs/testing/

Yes I do consider this a bug. One that has been present for a VERY VERY long time.

In my thinking, if the source image is not CMYK, and thus does NOT contain a black channel, that image should be treated as a greyscale source for the black channel data. This is basically what CopyOpacity does.

The way around this is to use -combine with four greyscale channel images to build the CMYK image.

Alternative you can use -channel K -combine to convert a single greyscale image to a CMYK image with only the back channel as valid, then use CopyBlack to merge it into the other image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

Re: Compose CMYK Files Using CompositeImageChannel function

Post by diuming »

Dear Master,

Sorry! I just focus on C function, not command.

Your mean is use CombineImages() function. Right?

Thank for quickly reply.

Diuming
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Compose CMYK Files Using CompositeImageChannel function

Post by anthony »

Correct. BUT just as in the Command ling API there is a trick to 'combining' RGB greyscale channel images into a non-RGB image.

You first need to 'set' (that is just set, don't actually change) the colorspace of the incoming images, so when CombineImages() creates a new image, it creates it in the correct color space. It is a little bit of a 'hack' but it works for generating the special 4 channel CMYK image.

The details were worked out for command line API, but the exact same equivalent method is used for any other API too.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

Re: Compose CMYK Files Using CompositeImageChannel function

Post by diuming »

I got it. :D
thank you so much!!

Diuming
Post Reply