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

This script will process a folder and it's sub folders of JPG's and save overwrite the originals with the new SFW JPG's

Alter the quality to suit.


[code]


var imageFolder = Folder.selectDialog("Select the folder with JPGs to process");

if (imageFolder != null)  processFolder(imageFolder);


function processFolder(folder) {

    var fileList = folder.getFiles()

     for (var i = 0; i < fileList.length; i++) {

        var file = fileList[i];

  if (file instanceof File && file.name.match(/\.jpg$/i)) {

                 open(file);

var doc = app.activeDocument;

var strtRulerUnits = app.preferences.rulerUnits;

var strtTypeUnits = app.preferences.typeUnits;

app.preferences.rulerUnits = Units.PIXELS;

app.preferences.typeUnits = TypeUnits.PIXELS;

var saveFile = new File(decodeURI(activeDocument.fullName.fsName));

saveFile.remove();

SaveForWeb(saveFile,60); // set quality to suit

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

app.preferences.rulerUnits = strtRulerUnits;

app.preferences.typeUnits = strtTypeUnits;     

        

  } else

if (file instanceof Folder) {

       processFolder(file);

     }

   }

}

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile = false;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = jpegQuality;

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

}

[/code]


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