我有这个脚本,我正在通过photoshops Scripts事件管理器运行,它使用" .jpg"然后将它们保存到网上并将质量降低到70%。
它运行绝对正常,直到它命中一个名称中包含百分比的文件,例如。 Background_(25%)。JPG。无论如何我可以改变这个脚本,以便我可以降低这些jpgs的质量以及我已经击中的那些?
由于
var imageFolder = Folder.selectDialog("Select the folder with JPGs to process");
if (imageFolder != null) processFolderJPG(imageFolder);
function processFolderJPG(folder) {
var fileList = folder.getFiles()
for (var i = 0; i < fileList.length; i++) {
var file = fileList[i];
if (file instanceof File && file.name.match(/\.jpg$/i)) {
open(file);
var docJPG = app.activeDocument;
var strtRulerUnitsJPG = app.preferences.rulerUnits;
var strtTypeUnitsJPG = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var saveFileJPG = new File(decodeURI(activeDocument.fullName.fsName));
saveFileJPG.remove();
SaveForWebJPG(saveFileJPG,70); // set quality to suit
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = strtRulerUnitsJPG;
app.preferences.typeUnits = strtTypeUnitsJPG;
} else
if (file instanceof Folder) {
processFolderJPG(file);
}
}
}
function SaveForWebJPG(saveFileJPG,jpegQuality) {
var sfwOptionsJPG = new ExportOptionsSaveForWeb();
sfwOptionsJPG.format = SaveDocumentType.JPEG;
sfwOptionsJPG.includeProfile = false;
sfwOptionsJPG.interlaced = 0;
sfwOptionsJPG.optimized = true;
sfwOptionsJPG.quality = jpegQuality;
app.activeDocument.exportDocument(saveFileJPG, ExportType.SAVEFORWEB, sfwOptionsJPG);
}
编辑:我需要文件保持相同的文件名。