【发布时间】:2016-12-22 18:45:32
【问题描述】:
我是 Photoshop 脚本的新手,所以请多多包涵。
到目前为止,我有以下脚本,但我不断收到我的 doc 对象引用无效的错误。任何人都可以帮助我正确分配我的文件,以便我可以在我的条件语句中使用它们吗?
还需要帮助以与现有文件名和扩展名相同的文件名和扩展名保存文档,即即使文件名的格式非常糟糕,如“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 -
不,这没有任何区别。同样的错误。
标签: image-processing photoshop