How to save psd layers in png using PSD-plugin for Paint.NET?

2.2k views Asked by At

How to save PSD layers in png using PSD-plugin for Paint.NET?

Trying to do this way:

System.Drawing.Image img;
var stream = new System.IO.MemoryStream();
var BRW = new PhotoshopFile.BinaryReverseWriter(stream);
var psd = new PhotoshopFile.PsdFile();
psd.Load("c:\\1.psd");
psd.Layers[0].Save(BRW);
stream.Seek(0, System.IO.SeekOrigin.Begin);
img = System.Drawing.Image.FromStream(stream, true, true);
img.Save("c:\\1.png", System.Drawing.Imaging.ImageFormat.Png);

But the line img = Image.FromStream(stream, true, true); throws "Parameter is not valid" exception.

Any other solutions via C#/C++ are also acceptable. Thanks in advance.

2

There are 2 answers

0
mhaenssgen On

The first solution does not work anymore with the latest version, use instead:

var psd = new PhotoshopFile.PsdFile("YourPhotoshop Path as string", Encoding.ASCII);

// or

var psd = new PhotoshopFile.PsdFile("Your Photoshop File Path as string", Encoding.Default);

Same with saving.

0
Rick Brewster On

Have you thought about asking the author of the PSD plugin? Paint.NET isn't licensed for use as an SDK, by the way, only as an application.