【问题标题】:How do I load a layer transparency and save as a path in the Photoshop JavaScript API?如何在 Photoshop JavaScript API 中加载图层透明度并保存为路径?
【发布时间】:2012-12-04 19:30:49
【问题描述】:

我是 javascripting 的新手,我正在尝试在 Photoshop 中处理大量图层,以将每个图层的加载选择输出为 ai 路径..

我遇到的问题是理解 selection.load 的通道 arg。

在 Photoshop 中,加载选择的下拉菜单显示通道名称为“layer_7 Transparency”。但是通过这个似乎不起作用。

 for(a=2;a<=AD.layers.length;a++){
    AD.layers[a-2].visible = 0;
    AD.layers[a-1].visible = 1;


    if((checkArray[a-1]!= 1)&&(checkArray[a-1]!= 2)){ 

        var channel = AD.channels.getByName(AD.layers[a-1].name+" Transparency");
        AD.selection.load(channel, SelectionType.REPLACE, false);

        AD.selection.makeWorkPath(1.0)

        newAIFile = new File(tempFolder+"/"+AD.layers[a-1].name+".ai");
        AD.exportDocument(newaiFile , ExportType.ILLUSTRATORPATHS , exportOptions)




    }
}

【问题讨论】:

    标签: javascript api save transparency photoshop


    【解决方案1】:

    在脚本中,集合中的第一层是最后添加的层。它位于 Document.artLayers 集合中的索引 0 处。

    // Get a reference to the first layer in the document
    var layerRef:Layer = app.activeDocument.layers.index(0);
    
    // Get a reference to a layer by name
    var baseLayer:Layer = app.activeDocument.artLayers.getByName("Background");
    

    因为图层集可以嵌套,所以您可能必须向下钻取包含的图层集才能到达特定图层或图层集:

    app.activeDocument.layerSets.index(0).layerSets.index(0); 
    

    参考文献

    【讨论】:

      猜你喜欢
      • 2015-01-23
      • 1970-01-01
      • 2015-06-17
      • 2013-07-06
      • 1970-01-01
      • 2020-03-28
      • 2015-06-24
      • 2015-10-17
      • 1970-01-01
      相关资源
      最近更新 更多