Python PSD layers?

I need to write a Python program for loading a PSD photoshop image, which has multiple layers and spit out png files (one for each layer). Can you do that in Python? I've tried PIL, but there doesn't seem to be any method for accessing layers. Help. PS. Writing my own PSD loader and png writer has shown to be way too slow.


  • Use Gimp-Python?

    You don't need Photoshop that way, and it should work on any platform that runs Gimp and Python. It's a large dependency, but a free one.

    For doing it in PIL:

    from PIL import Image, ImageSequence
    im ="spam.psd")
    layers = [frame.copy() for frame in ImageSequence.Iterator(im)]

    Edit: OK, found the solution:

    This will allow you to extract layers from a psd file with python without any non-python stuff.