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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With