Photoshop PSD Layer Extracton using C#


An example of exporting layers in Adobe Photoshop PSD file.

//import the photoshop package - taken from the link below
using Photoshop;
//create a new psdfile object
Photoshop.PsdFile psd = new Photoshop.PsdFile();
//load the file into the psdfile object
//loop through all the layers in the psd
for (int j = 0; j < psd.Layers.Count; j++) {
    //add each layer to a drawing image object
    System.Drawing.Image myPsdImage = ImageDecoder.DecodeImage(psd.Layers[j]);
    //save each layer as a png using the layers name as the file name
    myPsdImage.Save(pingsOutputPath + psd.Layers[j].Name + ".png");

The Using refers to a little library collection available from the below link.

This library collection is part of a screenshot application, the creator appears as an email address – see this url for more information about the application –

Using this as well as Adobe Photoshop’s actual DLLs – PS should be installed – one can complete a number of PS processing on images, it is arguable that this is not as effective as using actual PS, but is useful for saving as PNGs.

I have added a small vs2013 website to github to demonstrate.

You can download a VS2013 project for this from here