我对Photoshop脚本编写非常陌生,请多包容。
目前,我有以下脚本,但是我一直收到无效的文档对象引用错误。有人可以帮助我正确地分配我的文档,以便我可以在我的条件语句中使用它们吗?
还需要帮助将文档保存为与其原有的文件名和扩展名相同的格式,即使文件名的格式很恶劣,例如“horrible spaces.JPEG”
谢谢!
var inputFolder = Folder.selectDialog("Select a folder to process");
var fileList = inputFolder.getFiles("*.*"); //Use whatever extension you want or no extension to select all files
for(var i=0; i<fileList.length; i++) {
if (fileList[i] instanceof File && fileList[i].hidden == false) {
// get a reference to the new document
var doc = open(fileList[i])
}
// do the resizing. if the width of the document is already less than 500, then don't do anything. Otherwise resize too 500 wide, keep the aspect ratio, and change the resampling.
if (doc.width < "500px") {
// don't do anything
}
else {
doc.resizeImage(UnitValue(500,"px"),null,null,ResampleMethod.BICUBIC);
}
app.activeDocument.close();
}
"500px"
更改为500
。 - Mark Setchell