从PSD提取图层与ImageMagick,保留布局 [英] Extract layers from PSD with ImageMagick, preserving layout

查看:1634
本文介绍了从PSD提取图层与ImageMagick,保留布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ImageMagick从PSD中提取图层,并且使用以下内容获得所有图片:

  .psd image-%d.png 

但是生成的PNG图片尺寸不同,具体取决于实际内容的层。我想要的是提取所有的图层,但它们都具有相同的大小,所以我可以很容易地把它们放在彼此的后面,并有一切排队,就像它在原来的PSD。 p>

如果它有助于可视化,这是我目前使用上面的命令得到:

 
+ ---- +
| A | + - + + - +
| | = | A | + | B |
| B | + - + + - +
+ ---- +

我想要的是:

 
+ ---- + + ---- + + ---- +
| A | | A | | |
| | = | | + | |
| B | | | | B |
+ ---- + + ---- + + ---- +

透明背景,以便我可以这样做:

 
+ ---- + + ---- +
| A | | A | +
| | = | ||
| B | | B ||
+ ---- + + ---- + |
+ ---- +



我不会以任何方式绑定ImageMagick,所以如果有另一个/ p>

解决方案

键入以从PSD文件中提取第2层:

  convert< filename> .psd [0]< filename> .psd [2] \(-clone 0  - alpha透明\)-swap 0 + delete -coalesce -compose src-over -composite< extract-filename> .png 


b $ b

这会创建一个与PSD文件大小相同的透明画布,然后将其与第2层保持原始布局(-coalesce)。



希望它有助于


I'm using ImageMagick to extract layers from a PSD, and it gets them all out fine with:

convert image.psd image-%d.png

But the resulting PNG images are of varying dimensions, depending on the actual contents of the layer. What I'd like is to extract all the layers, but have them all the same size, so that I can easily lay them on top of each other later, and have everything line up just as it did in the original PSD.

If it helps to visualise it, this is what I'm currently getting with the command above:

+----+
|A   |   +-+   +-+
|    | = |A| + |B|
|   B|   +-+   +-+
+----+

And what I want is:

+----+   +----+   +----+
|A   |   |A   |   |    |
|    | = |    | + |    |
|   B|   |    |   |   B|
+----+   +----+   +----+

With the resulting images having a transparent background so that I can do this:

+----+   +----+ 
|A   |   |A   |+
|    | = |    ||
|   B|   |   B||
+----+   +----+|
          +----+

I'm not in any way tied to ImageMagick, so if there's another (preferably command-line) tool that can achieve this, that's fine.

解决方案

type this to extract the layer number 2 from a PSD file:

convert <filename>.psd[0] <filename>.psd[2] \( -clone 0 -alpha transparent \) -swap 0 +delete -coalesce -compose src-over -composite <extracted-filename>.png

this creates first a transparent canvas with the same size of the PSD file then combines it with the layer 2 keeping it's original layout (-coalesce)

hope it helps

这篇关于从PSD提取图层与ImageMagick,保留布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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