I am trying to use Magick.Net to convert an GDI+ bitmap which is RGB to a CMYK tiff. I can convert the GDI+ bitmap to various RGB image formats and color profiles, but when I try to create a CMYK output opening the resulting tiff in photoshop it will is still be RGB and it says no color profile is attached.
The code I use to create the MagickImage is
var bitmapData = image.LockBits(new Rectangle(Point.Empty, image.Size), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var bytes = new byte[image.Width * image.Height * 4];
Marshal.Copy(bitmapData, bytes, 0, bytes.Length);
var magick = new MagickImage(bytes, new PixelReadSettings(width, height, StorageType.Char, "BGRA"));
and I then do the conversion with
magick.AddProfile(ColorProfile.SRGB);
magick.AddProfile(ColorProfile.USWebCoatedSWOP);
magick.ColorSpace = ColorSpace.CMYK;
magick.Settings.ColorSpace = ColorSpace.CMYK;
and save the image using
magick.Format = MagickFormat.Tiff;
magick.Settings.Compression = CompressionMethod.LZW;
magick.Write(stream);
What do I need to do to get the output tiff to be CMYK?
I've found out what my problem was. We had solved a previous issue applying the sRGB profile to images which were grey scale by setting the magick.ColorType property to TrueColor. It appears you can't have this set for CMYK images as removing it solved the problem.