public static void Run()
{
// ExStart:ExportPSDLayerToRasterImage
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_PSD();
// Create an instance of Image class and load PSD file as image.
using (Image image = Image.Load(dataDir + "samplePsd.psd"))
{
// Cast image object to PSD image
var psdImage = (PsdImage)image;
// Create an instance of PngOptions class
var pngOptions = new PngOptions();
pngOptions.ColorType = PngColorType.TruecolorWithAlpha;
// Loop through the list of layers
for (int i = 0; i < psdImage.Layers.Length; i++)
{
// Convert and save the layer to PNG file format.
psdImage.Layers[i].Save(string.Format("layer_out{0}.png", i + 1), pngOptions);
}
}
// ExEnd:ExportPSDLayerToRasterImage
}
}