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 properties of it, but it’s not success.

W:100% – H:75%


=> W:200% – H:150%


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

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



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; = true;

  // Ok....
  myWindow.add("button", undefined, "OK");
  if ( == 1) return myText.text;


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

In order to use the script currently:

  1. Open a new psd, create 3 or so different colored smart objects using the rectangle tool.
  2. Then run the script.
  3. Try entering a value like 50. This should result in each object
    being resized to 50% of its current size.
  4. 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.

Source : Link , Question Author : Tin Le , Answer Author : Ovaryraptor

Leave a Comment