Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 200
Brock123 Avatar asked Jul 20 '11 09:07

Brock123


People also ask

What are psd tools3?

psd-tools3 is a package for reading Adobe Photoshop PSD files as described in specification to Python data structures. This is a fork of psd-tools that adds a couple of enhancements to the original version.


1 Answers

Use Gimp-Python? http://www.gimp.org/docs/python/index.html

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 = Image.open("spam.psd")
layers = [frame.copy() for frame in ImageSequence.Iterator(im)]

Edit: OK, found the solution: https://github.com/jerem/psdparse

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

like image 106
agf Avatar answered Sep 17 '22 23:09

agf