activeDocument.mergeVisibleLayers();
命令只是将图像展平为背景图层。
我正在寻找一种方法将所有图层合并到一个新图层,该图层保持在所有其他图层的顶部,例如图层 - >合并可见(Ctrl + Shift + E)Photoshop命令。
那可能吗?
不确定这是否是最佳解决方案,但它对我有用:
// Copy all visible layers to clipboard (true = merged)
activeDocument.activeLayer.copy(true);
// then paste them (creates a new layer)
activeDocument.paste();
The answer by George与透明图像不兼容(它会裁剪透明度并将粘贴的图像与中间对齐)。这是一个简单执行与the Scripting Listener plug-in一起使用的Merge Visible命令的脚本:
var idMrgV = charIDToTypeID("MrgV");
executeAction(idMrgV, undefined, DialogModes.NO);