Hello, I have a pretty basic Photoshop script for resizing and saving various iterations of an image. It is set to work on a folder of images.
The script works great...for about 12-15 images and then it stops. No error message is displayed.
Typically we are running this script on Canon Raw files (CR2). I'm guessing it's some sort of a memory issue? Not sure
Environment: Photoshop CC under OSX 10.8.5
Any tips would be greatly appreciated!!!
Code: Select all///#target photoshop
var inFolder = Folder.selectDialog("Please select image folder");
if(inFolder != null){
var fileList = inFolder.getFiles(/\.(jpg|tif|psd|bmp|gif|cr2|png|)$/i);
}
for(var a = 0 ;a < fileList.length; a++)
{
var docRef = open(fileList[a]);
/// Write our copyright to the file metadata ///////////////////////////////////////////////////////////////
var doc = activeDocument;
doc.info.ownerUrl = "http://www.jarvisphotography.com"
doc.info.copyrightNotice = "Copyright (c) 2014 Jarvis Photography, Stateline, NV USA"
doc.info.copyrighted = CopyrightedType.COPYRIGHTEDWORK
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// Save HiRes Color //////////////////////////////////////////////////////////////////////////////////
var docName = activeDocument.name;
var docPath = activeDocument.path.parent + "/MasterImageSet/HighResolution_ForPrinting/Color";
var docNAME = docName.split('.');
var targetName = docNAME[0];
var saveFile = new File(docPath+'/'+targetName+'.jpg');
SaveJPEG(saveFile, 10) ///Can be 1-12
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// Save Proof Image /////////////////////////////////////////////////////////////////////////////////
var docRef = app.activeDocument;
///Determine the orientation of the image before converting
if(docRef.width > docRef.height){
docRef.resizeImage(UnitValue(2000, "px"), undefined, 300, ResampleMethod.BICUBIC);
}else{
docRef.resizeImage(undefined, UnitValue(2000, "px"), 300, ResampleMethod.BICUBIC);
}
var docName = activeDocument.name;
var docPath = activeDocument.path.parent + "/Proofs";
var docNAME = docName.split('.');
var targetName = docNAME[0];
var saveFile = new File(docPath+'/'+targetName+'.jpg');
SaveJPEG(saveFile, 8) ///Can be 1-12
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// Save LowRes Color /////////////////////////////////////////////////////////////////////////////////
var docRef = app.activeDocument;
///Determine the orientation of the image before converting
if(docRef.width > docRef.height){
docRef.resizeImage(UnitValue(1000, "px"), undefined, 300, ResampleMethod.BICUBIC);
}else{
docRef.resizeImage(undefined, UnitValue(1000, "px"), 300, ResampleMethod.BICUBIC);
}
var docName = activeDocument.name;
var docPath = activeDocument.path.parent + "/MasterImageSet/LowResolution_ForEmailWeb/Color";
var docNAME = docName.split('.');
var targetName = docNAME[0];
var saveFile = new File(docPath+'/'+targetName+'.jpg');
SaveJPEG(saveFile, 8) ///Can be 1-12
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Save HiRes BlackWhite //////////////////////////////////////////////////////////////////////////////
var docRef = app.activeDocument;
docRef.activeHistoryState = docRef.historyStates[4] ///the entry in the history pallete that we want to return to before running the black and white filter
///From Script Listener.
///Convert to Black and White
var idMk = charIDToTypeID( "Mk " );
var desc33 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref17 = new ActionReference();
var idAdjL = charIDToTypeID( "AdjL" );
ref17.putClass( idAdjL );
desc33.putReference( idnull, ref17 );
var idUsng = charIDToTypeID( "Usng" );
var desc34 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc35 = new ActionDescriptor();
var idpresetKind = stringIDToTypeID( "presetKind" );
var idpresetKindType = stringIDToTypeID( "presetKindType" );
var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
desc35.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
var idRd = charIDToTypeID( "Rd " );
desc35.putInteger( idRd, 40 );
var idYllw = charIDToTypeID( "Yllw" );
desc35.putInteger( idYllw, 60 );
var idGrn = charIDToTypeID( "Grn " );
desc35.putInteger( idGrn, 40 );
var idCyn = charIDToTypeID( "Cyn " );
desc35.putInteger( idCyn, 60 );
var idBl = charIDToTypeID( "Bl " );
desc35.putInteger( idBl, 20 );
var idMgnt = charIDToTypeID( "Mgnt" );
desc35.putInteger( idMgnt, 80 );
var iduseTint = stringIDToTypeID( "useTint" );
desc35.putBoolean( iduseTint, false );
var idtintColor = stringIDToTypeID( "tintColor" );
var desc36 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc36.putDouble( idRd, 225.000458 );
var idGrn = charIDToTypeID( "Grn " );
desc36.putDouble( idGrn, 211.000671 );
var idBl = charIDToTypeID( "Bl " );
desc36.putDouble( idBl, 179.001160 );
var idRGBC = charIDToTypeID( "RGBC" );
desc35.putObject( idtintColor, idRGBC, desc36 );
var idBanW = charIDToTypeID( "BanW" );
desc34.putObject( idType, idBanW, desc35 );
var idAdjL = charIDToTypeID( "AdjL" );
desc33.putObject( idUsng, idAdjL, desc34 );
executeAction( idMk, desc33, DialogModes.NO );
var docName = activeDocument.name;
var docPath = activeDocument.path.parent + "/MasterImageSet/HighResolution_ForPrinting/BlackWhite";
var docNAME = docName.split('.');
var targetName = docNAME[0];
var saveFile = new File(docPath+'/'+targetName+'.jpg');
SaveJPEG(saveFile, 10) ///Can be 1-12
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Save LowRes BlackWhite /////////////////////////////////////////////////////////////////////////////////
var docRef = app.activeDocument;
///Determine the orientation of the image before converting
if(docRef.width > docRef.height){
docRef.resizeImage(UnitValue(1000, "px"), undefined, 300, ResampleMethod.BICUBIC);
}else{
docRef.resizeImage(undefined, UnitValue(1000, "px"), 300, ResampleMethod.BICUBIC);
}
var docName = activeDocument.name;
var docPath = activeDocument.path.parent + "/MasterImageSet/LowResolution_ForEmailWeb/BlackWhite";
var docNAME = docName.split('.');
var targetName = docNAME[0];
var saveFile = new File(docPath+'/'+targetName+'.jpg');
SaveJPEG(saveFile, 8) ///Can be 1-12
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
//FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality; //1-12
activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}
}
Again, thanks for any help.
Eric