Photoshop scripting. Get image dimensions to clipboard


Often I save lots of versions of the same image with different dimensions so I usually include them in filename. It pisses me off to go and check dimensions for every document before saving it so I'd love to automate this. I need a script that gets document dimensions and copies them to clipboard in 000x000 format so I can paste them in "Save as" dialog. Two scripts: In pixels or millimeters. I'm in the process of learning to script myself but it takes time. And I badly want this script right now :) Please help! Thanks a lot!

8/12/2014 1:54:00 PM

Eureka! This script will use active document's width and height as the file name and open the save dialog box with the file name preset for you. Choose a folder and save.

var saveOptions = new JPEGSaveOptions( );  
saveOptions.embedColorProfile = true;  
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;  
saveOptions.matte = MatteType.NONE;  
saveOptions.quality = 12; // image quality (0,12)
var w = app.activeDocument.width.toString().replace(' px', '');
var h = app.activeDocument.height.toString().replace(' px', '');
var file = new File(w + 'x' + h + '.jpg');
var filePath = file.saveDlg("Select Folder");
var saved = app.activeDocument.saveAs( filePath, saveOptions, true );

How to implement:

  • Save as widthXheight.jsx
  • Paste file in your Presets\Scripts folder
  • Reload Photoshop
  • with a file open, click File > Scripts > widthXheight
8/12/2014 3:41:00 PM