我的客户需要多种作物来处理大量图像,但不断更改指南。由于我需要继续处理文件,我希望将指南从单个文件导入到每个文件中,以便我可以在最后使用它们进行批处理。以下脚本似乎与我发现的一样接近,但它在第6行崩溃了:
file = app.openDialog();//opens dialog,choose one image
if(file[0]){ //if you have chosen an image
app.load(file[0]); //load it into documents
backFile= app.activeDocument; //prepare your image layer as active document
backFile.resizeImage(width,height); //resize image into given size i.e 640x480
backFile.selection.selectAll();
backFile.selection.copy(); //copy image into clipboard
backFile.close(SaveOptions.DONOTSAVECHANGES); //close image without saving changes
doc.paste(); //paste selection into your document
doc.layers[0].name = "BackgroundImage"; //set your layer's name
}
非常感谢任何帮助!
答案 0 :(得分:1)
有些变量尚未设置:例如doc,width和height。如果在开始时你会添加
,它会起作用var width = 640;
var height= 480;
var doc = activeDocument;
但我不确定这是你要找的东西,因为这个脚本调整了它打开的图像的大小,然后将这个已调整大小的图像粘贴到1个打开的文档中。如果您需要将1张图像粘贴到您拥有的所有文档中,我会执行以下操作:
var f = File.openDialog ();
if (f) {
backFile= app.open(f);
backFile.selection.selectAll();
backFile.selection.copy(); //copy image into clipboard
backFile.close(SaveOptions.DONOTSAVECHANGES); //close image without saving changes
for (i=0; i<documents.length; i++) {
activeDocument = documents[i];
activeDocument.paste();
}
}