如何在python中从多个图像创建psd分层文件 [英] How to create a psd layered file from multiple image in python

查看:246
本文介绍了如何在python中从多个图像创建psd分层文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个psd文件,以将多个图像合并为一个分层的图像.
我看到 gimp命令行似乎是唯一可以执行此操作的方法,但是我想使此工具独立于其他工具.
还有其他解决方法吗?

有关信息,我已经研究过 psd-tools psdparse pypsd ,该功能允许从psd中提取图层以制作单独的图像,但并非相反.

o/

解决方案

我前段时间为一个坚定地使用Django构建在线照片编辑器的客户研究了这个问题.

为获得正确的结果,您可能必须依赖某种形式的本机编译库.由于大多数Python模块都会包装这些库,因此您可以坚持使用 import os;os.system("gimp ...")来自子流程导入调用;调用(["gimp","-i -b'(mygimpscript" test.psd"2000 2000)'..."])使用 blogger :

如果您是开发人员,则PSD的复杂性使编写文件格式成为可能读者/作家更加困难.当然,PSD从来没有设计成打算是一种交换格式.

当前工作中的 自述文件 进度 psd工具,也表明优秀的psd编写者仍然很难甚至难以捉摸


尽管有介绍,

要与 alpha blending metadata 完全兼容,您唯一的选择是使用Adobe专有的基于COM32的psd库.此处是示例,并且此处另一个.

优点是文档水平高.缺点是您可能会受平台限制.

不幸的是,答案仍然是:

不,目前还没有办法以满足生产水平的方式在纯Python中编写psd文件..

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/

解决方案

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,

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.

这篇关于如何在python中从多个图像创建psd分层文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆