You are here

Extracting layers from PSD

Hi all,

There are a few scripts floating around that allow you to extract layers from a PSD file and save them into individual PNGs or JPEGs. What they all seem to have in common is:

1) Require the GUI (i.e. don't give the option run in non-interactive mode)
2) As a result of (1), don't allow for filename selection from command line by giving the path to the file
3) They all trim the new images to remove extra space around the image and therefore lose the positioning of the layer
4) Auto-generate names for the new images rather than use the existing name of the layer.

I've tried doing the above using a combination of PIL and Imagemagick with some success, but sometimes one or the other chokes on some PSD files. GIMP seems to have no problem reading any PSD file I throw at it, but again, with the above limitations.

So I'm looking for something like:

gimp -i -b '(extract-layers-for-martin "/path/to/photoshop-file.psd")'

Anybody have a script that does the following or knows how to amend an existing one that's out there? (Saul Goode has a great script that works, but it doesn't meet conditions 1-4).


I was searching for the same kind of tool and found psdparse:

It works great for me, but I still would like to test other apps, so please let me know if you found something else.

Extract of the help file:
"This utility parses and prints a description of various structures
inside an Adobe Photoshop(TM) PSD or PSB format file.
It can optionally extract raster layers and spot/alpha channels to PNG files.

A reasonable amount of integrity checking is performed. Corrupt images may
still cause the program to give up, but it is usually much more robust
than Photoshop when dealing with damaged files: It is unlikely to crash,
and it recovers a more complete image.

Tested with PSDs created by PS 3.0, 5.5, 7.0, CS and CS2,
in Bitmap, Indexed, Grey Scale, CMYK and RGB Colour modes
and 8/16 bit depths, with up to 53 alpha channels.

32-bit channels can be extracted, but only to 'raw' format files."


I've never seen psdparse before, but thanks for posting it. What I ended up doing was writing a python-fu plugin for gimp. I'd be curious to see if psdparse is faster than using gimp, I'd suspect it is. There's quite a bit of overhead in starting gimp up from command line each time.

Hi littleheroes,

would you please share your python-fu plugin for me to test it?
I am looking for the exact same functionality as you.

Thank you in advance.


Subscribe to Comments for "Extracting layers from PSD"