問題描述
如何使用 Python/ImageMagick/Wand 保存多層 PSD (How to save multi‑layer PSD with Python/ImageMagick/Wand)
我需要使用 Python 保存一個多層 PSD。我找到的唯一解決方案是使用 ImageMagick,因為 Python PSD 庫(例如 psd‑tools 和 psd‑tools3)不支持圖層編寫。使用 ImageMagick,命令是:
convert ./image1.png ./image2.png ./image3.jpg ‑clone 0 final.psd
但我無法找到如何在 Python/Wand 代碼中翻譯此類命令。
參考解法
方法 1:
Possible solution with wand would be something like..
from wand.image import Image
with Image(filename="./image1.png") as img:
img.read(filename="./image2.png")
img.read(filename="./image3.jpg")
img.read(filename="./image1.png") # ‑clone 0
img.save(filename="final.psd")
</code></pre>
.. but I"m sure there's cleaner ways.
(by Nico、emcconville)
參考文件