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

Copy and paste the following code into ExtendScript (this gets installed with Photoshop) and run the script.

It will prompt for the folder of files to be processed. (I am guessing they are JPG)

The files will be split and put into anew folder called Processed off the selected folder.


[code]

#target photoshop

app.bringToFront();

function main(){

var inputFolder= Folder.selectDialog ("Please select folder to process");

if(inputFolder == null) return;

var fileList = inputFolder.getFiles("*.jpg");

var outFolder = Folder(inputFolder +"/Processed");

if(!outFolder.exists) outFolder.create();

for(var z in fileList){

    open(fileList[z]);

var doc = activeDocument;

var Name = decodeURI(fileList[z].name.replace(/\.[^\.]+$/, ''));

var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

var LB=[];

LB[0] = 0;

LB[1] = 0;

LB[2] = 512;

LB[3] = doc.height.value;

doc.selection.select([[LB[0],LB[1]], [LB[2],LB[1]], [LB[2],LB[3]], [LB[0], LB[3]]], SelectionType.REPLACE, 0, false);

var savedState = doc.activeHistoryState;

executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );

saveFile= File(outFolder + "/" + Name + "-512.jpg");

SaveForWeb(saveFile,80);

doc.activeHistoryState = savedState;

doc.selection.invert();

executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );

saveFile= File(outFolder + "/" + Name + "-rest.jpg");

SaveForWeb(saveFile,80);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

app.preferences.rulerUnits = startRulerUnits;

}

}

main();

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile = false;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = jpegQuality; //0-100

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

}



[/code]


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