95%的时间可以正常工作。但是对于其余的5%,有时会给出:
错误:发生一般的Photoshop错误。此功能可能在此版本的Photoshop中不可用。 -> app.activeDocument.saveAs()
通常,在几台Photoshop /或整个机器重新启动后,它确实消失了。
似乎与以下内容相似:Photoshop Javascript scripting saving and closing document
在此建议中提出了完整的建议。我做到了尽管错误仍然存在。
它发生在CS6和CC 2014上。
欢迎提出任何可能导致它的想法或建议。
//Output location
folderJpegSave = "/Volumes/Hams Hall Workspace/Ecom_Staging/Jpegs_for_Hybris";
folderTiffSave = "/Volumes/Hams Hall Workspace/Ecom_Staging/Images_Today";
//Size
var fWidth = 3000;
var fHeight = 3000;
var hybrisSize=2000;
var docRef = activeDocument;
//History States & Units
app.purge(PurgeTarget.ALLCACHES);
app.preferences.rulerUnits = Units.PIXELS;
// Convert to sRGB
app.activeDocument.convertProfile( "sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true );
//Make it 1:1 Ratio (Square)
if (docRef.height != docRef.width) {
//Make sure that Image > Mode is set to RGB
docRef.changeMode(ChangeMode.RGB);
if (docRef.height > docRef.width) {
docRef.resizeImage(null, UnitValue(fHeight, "px"), null, ResampleMethod.BICUBIC);
} else {
docRef.resizeImage(UnitValue(fWidth, "px"), null, null, ResampleMethod.BICUBIC);
}
// Makes background white
var white = new SolidColor();
white.rgb.hexValue = "FFFFFF";
app.backgroundColor = white;
// Resize Canvas
app.activeDocument.resizeCanvas(UnitValue(fWidth, "px"), UnitValue(fHeight, "px"));
}
//Save copy of an "Original" into Tiff Folder (Images_Today)
app.activeDocument.save();
var saveTIFF = new TiffSaveOptions();
saveTIFF.layers = false;
saveTIFF.imageCompression = TIFFEncoding.TIFFLZW;
saveTIFF.alphaChannels = false;
app.activeDocument.saveAs(new File(folderTiffSave + "/" + docRef.name), saveTIFF);
//Flatten document before saving as JPEG
app.activeDocument.flatten();
// Delete alpha Channel
app.activeDocument.channels.removeAll();
app.activeDocument.guides.removeAll();
app.activeDocument.pathItems.removeAll();
//Resize Image
app.activeDocument.resizeImage(hybrisSize, undefined, undefined, ResampleMethod.BICUBICSHARPER);
//Save JPEG to Jpeg Folder (Jpegs_for_Hybris)
app.activeDocument.save();
var saveJPEG = new JPEGSaveOptions();
saveJPEG.embedColorProfile = true;
saveJPEG.formatOptions = FormatOptions.STANDARDBASELINE;
saveJPEG.quality = 10;
app.activeDocument.saveAs(new File(folderJpegSave + "/" + docRef.name), saveJPEG);
//Close
app.activeDocument.close();