How to create a psd layered file from multiple image in python

被刻印的时光 ゝ 提交于 2021-02-06 12:55:50

问题


I need to create a psd file to merge several images into a single layered one.
I saw that the gimp command line seems to be the only way to be able to do, but I would like to make this tool-independent.
Would there be another solution ?

For info I already looked into psd-tools, psdparse, pypsd that allows extracting layers from a psd to make a separate image with it but not the other way around.

o/


回答1:


I had looked into that issue myself some time ago for a client who was adamant on building an online-photo editor using Django.

For proper results you will likely have to rely on a native compiled library in some form or another. As most Python modules will wrap these libraries, you could stick to import os; os.system("gimp ...") or from subprocess import call; call(["gimp", "-i -b '(mygimpscript "test.psd" 2000 2000)'..."]) using the GIMP command line for instance.

From an Adobe blogger:

If you’re a developer, PSD’s complexity makes writing a file format reader/writer more difficult. Of course, PSD was never designed as or intended to be an interchange format.

The Readme from the current-work-in-progress psd-tools, also suggests that good psd-writers are still hard or even elusive to come by.


Despite that introduction,

  • GIMP and Python would be a good combination.

  • Pillow 2 has some useful features as well.

For full compatibility with alpha blending, and metadata, the only option you got is using the proprietary COM32 based psd library from Adobe. Here is an example, and here another.

The advantage is a decent level of documentation. The disadvantage is that you will likely be platform bound.

Unfortunately the answer still appears to be:

No, there still is currently no way to write psd files in pure Python in a manner that would satisfy a productive level.



来源:https://stackoverflow.com/questions/18666920/how-to-create-a-psd-layered-file-from-multiple-image-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!