Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing Photoshop脚本,如果图像宽度大于X,请调整大小_Image Processing_Photoshop - Fatal编程技术网

Image processing Photoshop脚本,如果图像宽度大于X,请调整大小

Image processing Photoshop脚本,如果图像宽度大于X,请调整大小,image-processing,photoshop,Image Processing,Photoshop,我对Photoshop脚本非常陌生,所以请容忍我 到目前为止,我有下面的脚本,但我一直得到一个错误,我的文档对象引用无效。有人能帮我正确分配我的文档以便我在条件语句中使用它们吗 还需要帮助,以与已有文件名和扩展名相同的文件名和扩展名保存文档,即即使文件名的格式非常糟糕,如“可怕的空格.JPEG” 谢谢大家! var inputFolder = Folder.selectDialog("Select a folder to process"); var fileList = inputFol

我对Photoshop脚本非常陌生,所以请容忍我

到目前为止,我有下面的脚本,但我一直得到一个错误,我的文档对象引用无效。有人能帮我正确分配我的文档以便我在条件语句中使用它们吗

还需要帮助,以与已有文件名和扩展名相同的文件名和扩展名保存文档,即即使文件名的格式非常糟糕,如“可怕的空格.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();
var inputFolder=Folder.selectDialog(“选择要处理的文件夹”);
var fileList=inputFolder.getFiles(“*”)//使用您想要的扩展名或不使用扩展名来选择所有文件

对于(var i=0;i您是否在Extendscript工具包中运行此工具?请确保您的目标是photoshop,否则您的app.activeDocument对象将为空。当我以photoshop为目标时,您的脚本运行正常

保存文档-如果要保存原始文档,只需在关闭文档之前调用app.activeDocument.save()即可。如果要保存到新位置,请修改下面的代码段。有关选项对象的详细信息,请参阅photoshop安装目录中的JavaScript Ref文档

var options = new PhotoshopSaveOptions();
options.embedColorProfile = true;
options.alphaChannels = true; 

saveFile = new File( "/some/other/folder/" + app.activeDocument.name + ".psd")
app.activeDocument.saveAs(saveFile, options, false, Extension.LOWERCASE); 
app.activeDocument.close();

这是最后的工作脚本。希望这可以帮助其他人使用图像宽度条件调整图像大小。谢谢

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++) {
    open(fileList[i]);

    // do the resizing.  if the width of the document is already less than 500, then don't do anything. Otherwise resize to 500 wide, keep the aspect ratio, and change the resampling.
    if (activeDocument.width > "500") {
        activeDocument.resizeImage(UnitValue(500,"px"),null,72,ResampleMethod.BICUBIC);
        app.activeDocument.save();
    }

    app.activeDocument.close();
}
var inputFolder=Folder.selectDialog(“选择要处理的文件夹”);
var fileList=inputFolder.getFiles(“*.”;//使用您想要的扩展名或不使用扩展名来选择所有文件

对于(var i=0;i单击猜测…将
“500px”
更改为
500
否,这没有任何区别。相同的错误。