用于导出图层组合的Photoshop脚本 [英] Photoshop script to export layer combinations

查看:282
本文介绍了用于导出图层组合的Photoshop脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Photoshop脚本,让我将一组中的所有五个图层导出到一个png文件
- 与其他两个组中的每一个图层组合。


这有点模糊,所以我会试着说明我想要的
完成。有基组(红色,蓝色,黄色,橙色,
绿色)。然后有第二组包含第1,2和3层。
然后是第三组包含a,b,c和d。



我想
能够输出1_red_a.png,1_red_b.png,1_red_c.png,1_red_d.png,
1_blue_a.png, 1_blue_b.png,...


我对Photoshop脚本没有多少经验。这是可以实现的吗?如果有的话,是否有人愿意帮助我?

解决方案

我想我已经明白你想要什么了。我发现ExtendScript在编写代码时非常尴尬,并且倾向于使用更强大的日常工具在Photoshop之外进行自动化操作。我会选择ImageMagick和 bash 。 ImageMagick是免费的,可用于Windows,并且将两个图像组合在一起的基本命令是

  convert image1.png image2.png -composite result.png 

当然你可以改变任何或所有的 PNG 足以 TIF JPG 或您喜欢的任何内容。



因此,对于您的问题,我已经制作了一个包含几个组的示例文件来显示这个概念,如下所示:





Photoshop文件可以使用这里



放大图层调色板(在上图中右侧)查看我制作的2个组。



然后转到文件 - >脚本 - >将图层导出到文件,并选择如下选项:





这将为您导出以下文件:

  layers_0000s_0002_Layer A.png 
layers_0000s_0001_Layer B.png
layers_0000s_0000_Layer C.png
layers_0001s_0003_Layer 1 - Red.png
layers_0001s_0002_Layer 2 - Green.png
layers_0001s_0001_Layer 3 - Blue.png
layers_0001s_0000_Layer 4 - Magenta.png

请注意格式为 xxx< GROUP> s_xxx< LAYER> xxx.png



现在您可以轻松创建所有的排列具有此 bash 脚本的组。我认为Windows BATCH文件非常相似 - 虽然我只在胁迫下做Windows!

 #!/ bin / bash 
i = 0
#迭代0组文件
表示* 0s _ * .png; do
j = 0
#迭代第1组文件
for b in * 1s _ *。png; do
兑换$ a$ b-composite out _ $ {i} _ $ {j} .png
((j ++))
done
((i ++) )
完成

为您提供这些输出文件:

  out_0_0.png 
out_0_1.png
out_0_2.png
out_0_3.png
out_1_0.png
out_1_1.png
out_1_2.png
out_1_3.png
out_2_0.png
out_2_1.png
out_2_2.png
out_2_3.png

只是因为踢,我把它们全部放在一个蒙太奇中,你得到这个:





<请注意,如果你有3个组,你需要在你的脚本中使用第三个内部循环,并且将3个图像合成在一起的命令将更像这样(因为 -composite 选项获取前两个图像):

  convert image1.png image2.png -composite image3.png -composite result .png 

或者,你可能会发现你可以使用

  convert -background none image1.png image2.png image3.png -flatten result.png 


I want to make a Photoshop script that lets me export all five layers in a group to a png file - in combination with every single layer from 2 other groups.

It's a bit vague so I'll try to illustrate what I want to accomplish. There's the base group (red, blue, yellow, orange, green). Then there is a second group that contains layers 1,2 and 3. Then there's a third group that contains a, b, c and d.

I want to be able to export 1_red_a.png, 1_red_b.png, 1_red_c.png, 1_red_d.png, 1_blue_a.png, 1_blue_b.png, ...

I don't have much experience with Photoshop scripts. Is this something that can be accomplished? And if so, is anyone prepared to help me?

解决方案

I think I have got the idea of what you want. I find ExtendScript pretty awkward to code in and would tend to do automated stuff outside of Photoshop with more powerful, everyday tools. I would go with ImageMagick and bash. ImageMagick is free and available for Windows, and the basic command to composite two images on top of one another is

convert image1.png image2.png -composite result.png

Of course you can change any or all of the PNG suffices to TIF, JPG or whatever you like.

So, for your question, I have made a sample file with a couple of Groups to show the concept, like this:

The Photoshop file is avilable here.

Zoom into the Layers palette (on the right in the above image) to see the 2 groups I made.

Then go to File->Scripts->Export Layers to Files, and select the options like this:

That will export the following files for you:

layers_0000s_0002_Layer A.png
layers_0000s_0001_Layer B.png
layers_0000s_0000_Layer C.png       
layers_0001s_0003_Layer 1 - Red.png
layers_0001s_0002_Layer 2 - Green.png
layers_0001s_0001_Layer 3 - Blue.png
layers_0001s_0000_Layer 4 - Magenta.png

Note that the format is xxx<GROUP>s_xxx<LAYER>xxx.png

Now you can easily create all permutations of the groups with this bash script. I presume the Windows BATCH file would be pretty similar - though I only do Windows under duress !!!

#!/bin/bash
i=0
# Iterate over Group 0 files
for a in *0s_*.png; do
   j=0
   # Iterate over Group 1 files
   for b in *1s_*.png; do
      convert "$a" "$b" -composite out_${i}_${j}.png
      ((j++))
   done
   ((i++))
done

which gives you these output files:

out_0_0.png
out_0_1.png
out_0_2.png
out_0_3.png
out_1_0.png
out_1_1.png
out_1_2.png
out_1_3.png
out_2_0.png
out_2_1.png
out_2_2.png
out_2_3.png

Just for kicks, I put them all together in a montage and you get this:

Note that if you have 3 groups, you will need a third inner loop in your script, and the command to composite the 3 images together will be more like this (because the -composite option takes the two preceding images):

convert image1.png image2.png -composite image3.png -composite result.png

Alternatively, you may find you can use

convert -background none image1.png image2.png image3.png -flatten result.png

这篇关于用于导出图层组合的Photoshop脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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