javascript 在Adobe Photoshop脚本中导出时,文本颜色未正确更改

您所在的位置:网站首页 ps分层导出png javascript 在Adobe Photoshop脚本中导出时,文本颜色未正确更改

javascript 在Adobe Photoshop脚本中导出时,文本颜色未正确更改

#javascript 在Adobe Photoshop脚本中导出时,文本颜色未正确更改 | 来源: 网络整理| 查看: 265

我正在尝试创建一个脚本,该脚本将活动图层中的文本颜色更改为黑色,并将其导出为具有指定名称的PNG文件,然后将文本颜色更改为白色并再次导出为具有指定名称的PNG文件,并使用不同的颜色重复相同的过程(粉红色,蓝色,绿色,红色),并将它们保存为不同名称的PNG文件。脚本正在正确导出文件,但是所有的文件都被导出为黑色,而不是各自的颜色。我试过在重新着色之前添加= null,但是活动层不能等于null或未定义。有人能帮我弄清楚为什么我的脚本不能按预期工作,以及我如何修复它?下面是代码:

app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "000000"; var textLayerName = app.activeDocument.activeLayer.name; var newName = prompt("Enter a new name for the export", "black_" + textLayerName); var exportOptions = new ExportOptionsSaveForWeb(); exportOptions.format = SaveDocumentType.PNG; exportOptions.quality = 100; var file = new File("black " + newName + ".png"); app.activeDocument.exportDocument(file, ExportType.SAVEFORWEB, exportOptions); app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "FFFFFF"; var file2 = new File("white " + newName + ".png"); app.activeDocument.exportDocument(file2, ExportType.SAVEFORWEB, exportOptions); app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "fc82d8"; var file3 = new File("pink " + newName + ".png"); app.activeDocument.exportDocument(file3, ExportType.SAVEFORWEB, exportOptions); app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "63a8e7"; var file4 = new File("blue " + newName + ".png"); app.activeDocument.exportDocument(file4, ExportType.SAVEFORWEB, exportOptions); app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "0c6a27"; var file5 = new File("green " + newName + ".png"); app.activeDocument.exportDocument(file5, ExportType.SAVEFORWEB, exportOptions); app.activeDocument.activeLayer.textItem.color = new SolidColor(); app.activeDocument.activeLayer.textItem.color.rgb.hexValue = "a80000"; var file6 = new File("red " + newName + ".png"); app.activeDocument.exportDocument(file6, ExportType.SAVEFORWEB, exportOptions);```


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3