Python PSD layers?

前端 未结 5 1366
野的像风
野的像风 2021-02-03 14:39

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

5条回答
  •  孤城傲影
    2021-02-03 15:38

    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.

提交回复
热议问题