Mobile app version of vmapp.org
Login or Join
BetL875

: How to reset Vertical/Horizontal Scale of Smart Object to 100 percent by script I want to write a script to reset Vertical/Horizontal Scale of a Smart Object. I tried using ArtLayer and many

@BetL875

Posted in: #AdobePhotoshop #Scale #Script #Smartobject

I want to write a script to reset Vertical/Horizontal Scale of a Smart Object.
I tried using ArtLayer and many properties of it, but it's not success.

Example:
W:100% - H:75%

app.activeDocument.activeLayer.resize(200,200);


=> W:200% - H:150%

app.activeDocument.activeLayer.resize(100,100);


=> Nothing happened. ItW:200% - H:150%

Is there anyway to get Vertical/Horizontal Scale of a SO and set it to 100% (original scale)?

Thanks

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @BetL875

1 Comments

Sorted by latest first Latest Oldest Best

 

@Angie364

Here is "working" code:
#target photoshop
try {
var doc = app.activeDocument;

var layers = doc.artLayers;

var size = dialog();

var defaultRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PERCENT;


for (var i = 0; i < doc.artLayers.length -1; i++) {

var activeLayer = doc.artLayers.getByName(doc.artLayers[i].name);

var orUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PERCENT;

activeLayer.resize(size, size, AnchorPosition.MIDDLECENTER);

app.preferences.rulerUnits = orUnits;

}


} catch (e) {
// 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;

}


This is an imperfect solution based on how events must be ordered.

In order to use the script currently:


Open a new psd, create 3 or so different colored smart objects using the rectangle tool.
Then run the script.
Try entering a value like 50. This should result in each object
being resized to 50% of its current size.
Next try the script again (you don't have to undo anything in your
psd) and try typing 150.

This should result in objects 2.5 times their old size.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme