Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- - Photoshop script ( cs3+ )
- - Put in {photoshop_root}/presets/scripts/Resize Each Layer.jsx
- - Run from: File > Scripts > Resize Each Layer
- - ..or save the file where ever you want and run from there with: File > Scripts > Browse...
- EVERY LAYER is resized when you run the script.
- */
- /*
- <javascriptresource>
- <name>$$$/JavaScripts/resizeeachlayer/Menu=Resize Each Layer</name>
- <category>Resizing</category>
- <enableinfo>true</enableinfo>
- <eventid>64feff0a-8271-436f-8c59-d2105497d903</eventid>
- </javascriptresource>
- */
- try {
- // Currently active document.
- var doc = app.activeDocument;
- // All layers
- var layers = doc.artLayers;
- // Run dialog...
- var size = dialog();
- // Loop through every layer...
- for( var i = 0 ; i < doc.artLayers.length; i++ ){
- var activeLayer = doc.artLayers.getByName( doc.artLayers[ i ].name );
- // Save original ruler units
- var orUnits = app.preferences.rulerUnits;
- // Change rulerunits to percent
- app.preferences.rulerUnits = Units.PERCENT;
- // RESSIIIIIIIZE
- activeLayer.resize( size, size, AnchorPosition.MIDDLECENTER );
- // Roll back to original ruler units
- app.preferences.rulerUnits = orUnits;
- }
- } // try end
- catch( e ) {
- // remove comments below to see error for debugging
- // alert( e );
- }
- function dialog() {
- // Dialog box...
- var myWindow = new Window ("dialog", "Resize Each Layer");
- // Keeps things inline
- myWindow.orientation = "row";
- // Informational text
- myWindow.add ("statictext", undefined, "New size ( percentage ):");
- // This is the box where the size is inserted
- var myText = myWindow.add ("edittext", undefined, "");
- myText.characters = 5;
- myText.active = true;
- // Ok....
- myWindow.add ("button", undefined, "OK");
- if (myWindow.show () == 1) return myText.text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement