magick++ convert CMYK to RGB

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
luwenbin

magick++ convert CMYK to RGB

Post by luwenbin »

hi magick
I know how to use IM tool to covert a CMYK image to RGB, like this
" convert cmyk.jpg -profile USWebCoatedSWOP.icc -profile RGB.icc rgb.jpg".
But I want to know how to implement this funtion using magick++ APIs, could anyone give me some help? Many thanks!
luwenbin

Re: magick++ convert CMYK to RGB

Post by luwenbin »

No one knows?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: magick++ convert CMYK to RGB

Post by fmw42 »

try posting to viewforum.php?f=6
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick++ convert CMYK to RGB

Post by magick »

Try image.profile( "ICM", myProfile ) where myProfile is a blob. If your image does not already have a color profile associated with it, it assigns the profile. If it already has a profile it transforms the colorspace as dictated by both color profiles.
luwenbin

Re: magick++ convert CMYK to RGB

Post by luwenbin »

Thanks, magick. The original cmyk image has a profile, so I use the command
"convert cmyk.jpg -profile USWebCoatedSWOP.icc -profile RGB.icc rgb.jpg"
and get a rgb format file which has a confortable view. But if I use the following code to generate the rgb image,
the genareated image remains cmyk format and has a unconfortable view.

Blob rgbBlob;
string strIccRGBFile = "./icc/RGB.icc";
string strIccRGBContent = LoadFile(strIccRGBFile);
rgbBlob.update(strIccRGBContent.c_str(), strIccRGBContent.length());
image.profile("ICM", rgbBlob);


the original image has a profile as below:
Profiles:
Profile-8bim: 5562 bytes
Profile-exif: 4729 bytes
Profile-iptc: 7 bytes
unknown[2,0]:
Profile-xmp: 4844 bytes

When I use command "covert", the generated image has a profile as following:
Profiles:
Profile-8bim: 5562 bytes
Profile-exif: 4729 bytes
Profile-icc: 560 bytes
Adobe RGB (1998)
Profile-iptc: 7 bytes
unknown[2,0]:
Profile-xmp: 4844 bytes

But if I use the C++ code, the generated image has another profile
Profiles:
Profile-8bim: 5562 bytes
Profile-exif: 4729 bytes
Profile-iptc: 7 bytes
unknown[2,0]:
Profile-xmp: 4844 bytes

seems that the C++ code don't work...
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick++ convert CMYK to RGB

Post by magick »

We cannot reproduce the problem with ImageMagick 6.5.5-4, the current release. Our code looks like:

Code: Select all

  try {
    {
      Image my_image;
      my_image.read("cmyk.tif");
      Blob profile = Blob((void *) AdobeRGB1998Profile, 560);
      my_image.profile("icc", profile);
      my_image.write( "rgb.tif" );Photometric Interpretation: RGB color
    }
  } catch( Exception &error_ ) {
The resulting image returns these attributes as expected:
  • ...
    Photometric Interpretation: RGB color
    ...
    ICC Profile: <present>, 560 bytes
Post Reply