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!

Reply to thread

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);

};

[/CODE]


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top