Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

 

 

 

 

 
PhotoShop
Scripting
        by mlk : Hot Summer Month of 2004

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 ! (optionally you can add filesize, place a caption telling which pic is what quality etc...)

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


 
[ a smaller-scale version ]

Note
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;
 
  AD.flatten();
  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;
 
  for(a=0;a<=12;a++){
 
    jpgSaveFile = new File(initialFolder+"/scriptTemp"+ a+".jpg");
    jpgOptns.quality = a;
    AD.saveAs (jpgSaveFile ,jpgOptns , true, Extension.LOWERCASE);
  }
 
  for(a=0;a<=12;a++){
 
    var fileRef = new File(initialFolder + "/scriptTemp"+a+".jpg");
    open (fileRef);
    var openedFile = activeDocument;
    openedFile.selectAll;
    openedFile.layers[0].copy();
 
    activeDocument = AD
    AD.paste()
    openedFile.close(SaveOptions.DONOTSAVECHANGES);
    AD.layers[0].name = "approx. "+Math.round(fileRef.length/100)/10 +" kb"
    fileRef.remove();
    fileRef = null;
  }
 
  AD.layers[AD.layers.length-1].remove();
 
  if(docWidth>docHeight){
    var multipW=1;
    var multipH=13;
  }else{
    var multipW=13;
    var multipH=1;
  }
 
  AD.resizeCanvas((docWidth+1)*multipW,(docHeight+1)*multipH,AnchorPosition.TOPLEFT)
 
  for(a=13;a>=1;a--){
 
    if(multipW==1){
      AD.layers[a-1].translate(0,(13-a)*(docHeight+1))
    }else{
      AD.layers[a-1].translate((13-a)*(docWidth+1),0)
    }
  }
 
}else{
 
  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;


Note/Warning
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 of 11


 




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.