Page 1 of 1

magick++ convert CMYK to RGB

Posted: 2009-08-17T21:47:18-07:00
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!

Re: magick++ convert CMYK to RGB

Posted: 2009-08-18T21:03:08-07:00
by luwenbin
No one knows?

Re: magick++ convert CMYK to RGB

Posted: 2009-08-18T22:30:44-07:00
by fmw42
try posting to viewforum.php?f=6

Re: magick++ convert CMYK to RGB

Posted: 2009-08-19T06:00:15-07:00
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.

Re: magick++ convert CMYK to RGB

Posted: 2009-08-23T19:43:32-07:00
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...

Re: magick++ convert CMYK to RGB

Posted: 2009-08-27T18:26:12-07:00
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