How to create a psd layered file from multiple image in python
Question: 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/


Answer: 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](http://stackoverflow.com/questions/1168614/how-to-
create-a-layered-psd-file-from-command-line?rq=1) for instance.

From an Adobe
[blogger](http://blogs.adobe.com/jnack/2009/05/some_thoughts_about_the_psd_format.html):

> 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](https://github.com/kmike/psd-tools)_ from the current-work-in-
progress [psd-tools](https://github.com/kmike/psd-tools), also suggests that
good psd-writers are still hard or even elusive to come by.

* * *

Despite that introduction,

  * [GIMP and Python](http://www.gimp.org/docs/python/index.html) would be a good combination.

  * [Pillow 2](https://pypi.python.org/pypi/Pillow/2.0.0) 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](http://techarttiki.blogspot.co.at/2008/08/photoshop-scripting-with-
python.html) is an example, and
[here](http://peterhanshawart.blogspot.co.at/2012/05/python-and-photoshop-
code-snippets.html) 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_.**

