This project has moved. For the latest updates, please go here.

Separate() gives wrong channels

Sep 30, 2013 at 9:37 AM
Hello.
I'm trying to split psd file into several png channels. Psd file has 8 channels. I've tried all types of ImageMagick.Channel, but no one gave me right result.
var myImage = new MagickImage(@"MyPsdFile");
var channels = myImage.Separate(Channels.All);
var i = 0;
foreach (MagickImage image in channels)
{
    image.Format = MagickFormat.Png;
    image.Write(@"D:\sample_" + i + ".png");
    i++;
}
Please, help me with this issue.
Coordinator
Sep 30, 2013 at 9:45 AM
Edited Sep 30, 2013 at 9:45 AM
Are you talking about psd layers? If you want to read separate layers you should use the MagickImageCollection class.
using (MagickImageCollection images = new MagickImageCollection(@"MyPsdFile"))
{
  var i = 0;
  foreach (MagickImage image in images)
  {
      image.Format = MagickFormat.Png;
      image.Write(@"D:\sample_" + i + ".png");
      i++;
  }
}
Sep 30, 2013 at 9:59 AM
Not exactly. Image has only one layer, but this layer has 8 channels.
Just tried your example, collection contains one image.
Coordinator
Sep 30, 2013 at 10:25 AM
Your psd has 8 color channels? ImageMagick v6 only supports 4 to 5 pixel channels. You have to wait for the next release of Magick.NET that will use ImageMagick v7 which has no channel limit.
Sep 30, 2013 at 1:59 PM
Thank you for the answer.