4

I convert image based on CMYK to image based on RGB in the following way using ImageMagick(command Line) :

convert.exe -profile icc:JapanColor2001Coated.icc -colorspace cmyk input.jpg -profile icc:sRGB.icc -colorspace sRGB output.jpg 

And I challenge to convert image based on CMYK to image based on RGB in the following way using Magick.net

I show my sorce code below :

private MagickImage convertCMYKToRGB(MagickImage image)
        {
            image.AddProfile(new ColorProfile(@"C:\sRGB.icc"));
            image.ColorSpace = ColorSpace.sRGB;
            return image;
        }

but converted image using Image Magick(command line) is different from converted image using Magick.net

Maybe, I need to add ColorProfile to image based on CMYK not only to image based on RGB. but, I don't know how to add ColorProfile to input image(image based on CMYK)

How to set profile using Magick.net in the same way using Image Magick ?

dlemstra
  • 7,813
  • 2
  • 27
  • 43
user2798778
  • 41
  • 1
  • 2

1 Answers1

3

You should first add the old profile and then the new profile:

using (MagickImage image = new MagickImage("input.jpg"))
{
  // Tell ImageMagick what we're starting with
  image.AddProfile(new ColorProfile(@"C:\Path\JapanColor2001Coated.icc"));

  // Tell it to convert - the details are handled for you by the library
  image.AddProfile(ColorProfile.SRGB);

  // You're done. Save it.
  image.Write("output.jpg");
}

Another example here: https://magick.codeplex.com/wikipage?title=Convert%20image

Notice in the linked example they're converting from a standard CMYK, which means you don't need to load a custom icc profile - the standard CMYK is already in Magick.net, as ColorProfile.USWebCoatedSWOP.

If you need more help feel free to start a discussion here: https://magick.codeplex.com/discussions. If you post a message there please include a link to your source image.

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
dlemstra
  • 7,813
  • 2
  • 27
  • 43
  • 1
    Why is it necessary to add the "old profile"? Shouldn't that already be provided by the source image? – Brian Sep 26 '13 at 19:34
  • 2
    The conversion happens when one color profile is replaced with another profile. If the source image does not contain a color profile the conversion does not happen. Adding it will make sure the colors are converted. – dlemstra Sep 27 '13 at 23:57