tags:

views:

1996

answers:

5

Is there a library in C# that will allow me to read the layers in a photoshop file (PSD) and extract them as transparent images (PNG)?

Photoshop has a batch command that will extract all layers in individual files but there is no choice of transparent PNGs. My goal is to create a small utility program that will create combinations of layers as you like (for example think of creating a card deck).

+2  A: 

There's a nice article on CodeProject which might be helpful. And here's a thread on SO discussing PSD file format parsing with C#.

Darin Dimitrov
The SO discussion only talks about reading a photoshop file (so do the links). Unfortunately, the demo application in CodeProject article doesn't work with new CS3 formats. :(
pek
+2  A: 

You can do that with Photoshop COM.

Joan Venge
See in particular this article (http://www.pcpix.com/Photoshop/) on accessing the COM interface from .NET.
Matthew Flaschen
A: 

If you don't have Photoshop installed, then you may want to look at the code at http://frankblumenberg.de/doku/doku.php?id=paintnet:psdplugin for more sample code that loads PSD files.

Unfortunately, I don't know of a pre-existing PNG library that does what you want but the canonical library code for PNG file manipulation is located at http://www.libpng.org/pub/png/.

Zian Choy
+1  A: 

I found a code sample that does this in Java.

"Supports uncompressed or RLE-compressed RGB files only"

Also supports only older PSD versions :

"Does not support additional features in PS versions higher than 3.0"

Also ImageMagick handles PSD and has interfaces to many languages :

"Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), NMagick (Neko/haXe), MagickNet (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK)"
Savvas Dalkitsis
A: 

You can use 3rd party SDK to extract photoshop layers:

http://imaging.aurigma.com/advanced-psd-add-on.aspx

sfedor