我看了一下Photoshop CS5 脚本编写指南和 Photoshop CS5 JavaScript 参考 http://www.adobe.com/devnet/photoshop/scripting.html,但我找不到将文本写入纯文本文件的方法。有什么办法可以做到这一点吗?
我想记录的值bounds
文档中每个图层对象的。
有什么提示吗?
这对我有用,保存与原始文档同名的文本,但带有扩展名txt
:
function saveTxt(txt)
{
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if (Ext.toLowerCase() != 'psd')
return;
var Path = app.activeDocument.path;
var saveFile = File(Path + "/" + Name +".txt");
if(saveFile.exists)
saveFile.remove();
saveFile.encoding = "UTF8";
saveFile.open("e", "TEXT", "????");
saveFile.writeln(txt);
saveFile.close();
}
我不知道它是如何工作的,Photoshop 脚本是一团糟,我只是不断地将我找到的一些脚本混合在一起,直到它工作为止。
另外,如果有人需要这个,这里有一个脚本,它也将活动文档保存为png
image:
function savePng()
{
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if (Ext.toLowerCase() != 'psd')
return;
var Path = app.activeDocument.path;
var saveFile = File(Path + "/" + Name +".png");
if(saveFile.exists)
saveFile.remove();
var o = new ExportOptionsSaveForWeb();
o.format = SaveDocumentType.PNG;
o.PNG8 = false;
o.transparency = true;
o.interlaced = false;
o.includeProfile = false;
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, o);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)