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!
-
why not just directly rename the document with that info? why bother with pasting. On that note why not handle all scalings at the same time?– joojaaCommented Aug 12, 2014 at 14:13
-
@joojaa Because in most cases document hasn't been saved yet. And in most cases it's not simple scaling, it's the same layout in different versions, different proportions etc.– GrigoryCommented Aug 12, 2014 at 14:25
-
unsaved documents can have placeholder names, anyway clipboard actions are a bit complex in jsx.– joojaaCommented Aug 12, 2014 at 14:29
-
Can you test my solution out and let me know if it works for what you're doing.– Brian DillinghamCommented Aug 12, 2014 at 15:29
-
"it pisses me off to go and check dimensions for every document..." lol.– expiredninjaCommented Jan 29, 2015 at 16:06
Add a comment
|
1 Answer
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
-
1You probably need a external app for the clipboard action before cs6- creative cloud see: stackoverflow.com/questions/4066108/… for clipboard actions. I dont have cs 6 at home– joojaaCommented Aug 12, 2014 at 15:26
-
Yeah, I hit a wall on that so I just propagated the file name instead, negating the need for a clipboard and saving a step in the questioneer's process =) Commented Aug 12, 2014 at 15:28
-
Sure thats what i proposed, anyway presumably in newer PSes it works, cant test like i said no PS CC or cs6 at home– joojaaCommented Aug 12, 2014 at 15:30
-
Ah I just saw that, it wasn't so obvious for me haha Commented Aug 12, 2014 at 15:34
-
NP this is the better, clipboard is a extra step unless the OP needs some others stuff hes not saying, solution loose the double dot tough. (also if you script listen you can move the cursor to the front of the name saving a click, as far as i seem to recall)– joojaaCommented Aug 12, 2014 at 15:36