VI.iv Comparing the Saving Qualities of JPGs
Creating a huge jpg with all the saving qualities of one image.

What this script will do is open a new doc, save it thirteen times with the thirteen possible JPG saving quality steps (from 0 to 12), create a new document, put all the images in it, and voila ! (optionnally you can add filesize, place a caption telling which pic is what quality etc...)

Download .js code PS7 / CS
(right click and 'save as')

[Click for a larger view. Warning: big image]


The picture you see with the thumbnail was saved using quality '8' (otherwise it was a 4 megabytes files), hence the inutility of the script for that precise example.

displayDialogs = DialogModes.NO;

var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;

if ((documents.length > 0) && (activeDocument.saved)){

  var AD = activeDocument;
  var initialFolder = activeDocument.path;

  var docWidth = AD.width; //CS USERS change to AD.width.value here (do it too for height)
  var docHeight = AD.height;
  var docRes = AD.resolution;

  // Save options: you can change STANDARDBASELINE to OPTIMIZEDBASELINE
  // or PROGRESSIVE (in which case you must add jpgSaveOptions.SCANS = (equal 3, 4 or 5)

  var jpgOptns = new JPEGSaveOptions();
  jpgOptns.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgOptns.embedColorProfile = true;
  jpgOptns.matte = MatteType.NONE;
  jpgOptns = new JPEGSaveOptions;


    jpgSaveFile = new File(initialFolder+"/scriptTemp"+ a+".jpg");
    jpgOptns.quality = a;
    AD.saveAs (jpgSaveFile ,jpgOptns , true, Extension.LOWERCASE);


    var fileRef = new File(initialFolder + "/scriptTemp"+a+".jpg");
    open (fileRef);
    var openedFile = activeDocument;

    activeDocument = AD
    AD.layers[0].name = "approx. "+Math.round(fileRef.length/100)/10 +" kb"
    fileRef = null;


    var multipW=1;
    var multipH=13;
    var multipW=13;
    var multipH=1;





  alert("Either you have no document open or you haven't saved your work anywhere prior to the script \nSave your document first !");


preferences.rulerUnits = defaultRulerUnits;


Notice here that you can delete files from your computer with 'fileRef.remove();' so be careful when handling such functions, you could erase some files that were necessary/important to you.

Next, why Scripting isn't the dream tool either: Scripting Limitations (and changes with CS)

 page 9 / 11