What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Scripting Photoshop - Microsoft Excel Macro


yes, or you could call another script from the same position I.E.
Code:
var SCRIPTS_FOLDER =  decodeURI(app.path + '/' + localize('$$$/ScriptingSupport/InstalledScripts=Presets/Scripts')); 
$.evalFile( new File(SCRIPTS_FOLDER +  '/Name of your script.jsx'));
 
I know the reason why it is not working but I do not know a solution for it.

The final action (that I asked how to do in the previous message) that needs to be ran is a batch process. It takes all of the files that have been produced in a folder, and usually we would go to File > Automate > Batch and select the folder and the action and run it. As this part is not included in the code for it, it is not running it and producing an error.

Any ideas?
 
You could do all the resizes in the one script and all the saves, as an example.

Code:
#target photoshop;
app.bringToFront();
main();
function main(){
var inputFolder = Folder("/R/Marketing/Images/Batch Done");
if(!inputFolder.exists) {
alert("Input folder does not exist");
return;
}
var outputFolder = Folder("/R/Marketing/Images/Batch To Go");
if(!outputFolder.exists) outputFolder.create();
var csv = File.openDialog("/R/Inventory/Test","CSV File:*.csv");
if(csv == null) return;
csv.open("r");
csv.encoding = "UTF-8";
var fileList = csv.read().split("\n");
csv.close();
//start at 1 to exclude header line. 0 if no header line
for(var a = 1;a<fileList.length;a++){
if(fileList[a].length < 3) continue;
var line = fileList[a].split(",");
var file = File(inputFolder + "/" + line[0].toString());
if(!file.exists) continue;
app.open(file);
var doc = activeDocument;
var res = doc.resolution;
//amend to suit.
doAction("Whole","Pair_Kit_Batch");
var outFile = File(outputFolder + "/" + line[1].toString() + ".jpg");
SaveJPEG(outFile, 8);
/////////////////////////////////////////////////////////////////////
//Set restore point
var savedState = app.activeDocument.activeHistoryState;
var outFile = File("/R/Marketing/Images/Batch Size1" + "/" + line[1].toString() + ".jpg");
//resize document to 1024 pixels wide keeping constrain
doc.resizeImage(new UnitValue(1024,'px'), undefined, res, ResampleMethod.BICUBIC);
SaveJPEG(outFile, 8);
//Restore back
doc.activeHistoryState = savedState;
/////////////////////////////////////////////////////////////////////
//Set restore point
var savedState = app.activeDocument.activeHistoryState;
var outFile = File("/R/Marketing/Images/Batch Size2" + "/" + line[1].toString() + ".jpg");
//resize document to 1000 pixels wide keeping constrain
doc.resizeImage(new UnitValue(1000,'px'), undefined, res, ResampleMethod.BICUBIC);
SaveJPEG(outFile, 8);
//Restore back
doc.activeHistoryState = savedState;
/////////////////////////////////////////////////////////////////////
//Set restore point
var savedState = app.activeDocument.activeHistoryState;
var outFile = File("/R/Marketing/Images/Batch Size3" + "/" + line[1].toString() + ".jpg");
//resize document to 800 pixels wide keeping constrain
doc.resizeImage(new UnitValue(800,'px'), undefined, res, ResampleMethod.BICUBIC);
SaveJPEG(outFile, 8);
//Restore back
doc.activeHistoryState = savedState;
/////////////////////////////////////////////////////////////////////
//Set restore point
var savedState = app.activeDocument.activeHistoryState;
var outFile = File("/R/Marketing/Images/Batch Size4" + "/" + line[1].toString() + ".jpg");
//resize document to 600 pixels wide keeping constrain
doc.resizeImage(new UnitValue(600,'px'), undefined, res, ResampleMethod.BICUBIC);
SaveJPEG(outFile, 8);
//Restore back
doc.activeHistoryState = savedState;
/////////////////////////////////////////////////////////////////////
//duplicate the block of code for as many times as required
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
};
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
};
 
That is great Paul. Works very well. Thank you very much.

Final thing (and I promise this time!), is for one of the versions of the resize batch that we run, we have in the action to "Place" a psd file over the image which has a watermark on it.

The action looks like this:

Place
R:\Inventory\Images\Watermark\Watermark.psd
Center: center
Translate: 0cm 0cm

Is there a way of incorporating the "Place" into one of these resizes as well?
 

Back
Top