Skip to main content
Innotex Nico Tanne
Inspiring
May 11, 2021
Question

Smartobject size to 100%

  • May 11, 2021
  • 3 replies
  • 7895 views

Hello all,

is there a possibility to bring a smartobject to exactly 100% by script. This would help me a lot.

This topic has been closed for replies.

3 replies

JJMack
Community Expert
Community Expert
May 11, 2021

What do you mean by 100%.  and is the smart object a Placed image file. Place scale smart objects,  In fact place may scale a smart object twice.  Once because there are different print resolution  in the Place image File the  document it is placed into a document and second second scaling if the smart object layer does not fit on canvas and your Photoshop preferences is  set to resize during Place. 

 

Script can scale a smart  layer to fill some area and mask  it to the area aspect ratio and shape.  I do that all the time.  Scaling a  smart object layer object transform to 100% may not be the size you are expecting the object  to be because Place may have scaled the object because of different resolution are involve.  Smart object layer implementation is more complex then most users think.

 

New versions of Photoshop have reset place layers transform I do not know if that will reset the PPI scaling Place may as well at place resize and user transform. It may I did not test that though.

 

I just tested reset place layers transform will reset all transforming done to the smart object sizing  and warping but positioning is not changed  so if the  transforming also move the positioning that will not be reset.

JJMack
Innotex Nico Tanne
Inspiring
May 11, 2021

Hello JJMack,

I have a document with a resolution of, for example, 100 dpi and then place images with different resolutions (dpi) as Smart Objects.
In order for the print size to be correct, however, I have to set the smart objects to exactly 100%, so a simple reset of the transformation is unfortunately not possible.

Innotex Nico Tanne
Inspiring
May 12, 2021

What Image Aspect Ratio paper size and print  resolution are you writing about.  Images can be any size and have any aspect ratio.  You can change the size an image prints by changing the Print PPI resolution. That  will not change an image's aspect ratio. A wide panorama will still be a wide panorama  a portrait will remain a portrait and a landscape will remain a landscape.  You can resize any aspect ration image to fit on 8"x 10" paper however; only  images that have a 4:5 or 5:4 aspect ratio will fill the paper all other aspect ratio image will have boarders on two sides the image will fill just the height or width of the paper.


Good morning JJMack,
I mean the print size of the smart object, the aspect ratio and the document into which I load the smart objects do not matter at first.

The image is always brought to the correct size proportionally.
It can only happen that the image is larger than my workspace due to the print size, but I can fix this with a mask.
As an example:
I have a PSD with 200dpi and the canvas is 1cm x 1cm.
If I load this PSD as a smart object into a document with 100dpi, I have to set the size of the smart object to 100% so that the smart object is now also 1cm in size.
If I set the size back, the smart object is now 2cm big, but I don't want that.

 

Stephen Marsh
Community Expert
Community Expert
May 11, 2021

A fuction call/function that you will find on this forum in multiple scripts, where varSomeFile may be a variable to a single file or multiple files:

 

 

placeFile(varSomeFile, 100);

 

 

 

function placeFile(file, scale) {
    var idPlc = charIDToTypeID("Plc ");
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    desc2.putPath(idnull, new File(file));
    var idFTcs = charIDToTypeID("FTcs");
    var idQCSt = charIDToTypeID("QCSt");
    var idQcsa = charIDToTypeID("Qcsa");
    desc2.putEnumerated(idFTcs, idQCSt, idQcsa);
    var idOfst = charIDToTypeID("Ofst");
    var desc3 = new ActionDescriptor();
    var idHrzn = charIDToTypeID("Hrzn");
    var idPxl = charIDToTypeID("#Pxl");
    desc3.putUnitDouble(idHrzn, idPxl, 0.000000);
    var idVrtc = charIDToTypeID("Vrtc");
    var idPxl = charIDToTypeID("#Pxl");
    desc3.putUnitDouble(idVrtc, idPxl, 0.000000);
    var idOfst = charIDToTypeID("Ofst");
    desc2.putObject(idOfst, idOfst, desc3);
    var idWdth = charIDToTypeID("Wdth");
    var idPrc = charIDToTypeID("#Prc");
    desc2.putUnitDouble(idWdth, idPrc, scale);
    var idHght = charIDToTypeID("Hght");
    var idPrc = charIDToTypeID("#Prc");
    desc2.putUnitDouble(idHght, idPrc, scale);
    var idAntA = charIDToTypeID("AntA");
    desc2.putBoolean(idAntA, true);
    executeAction(idPlc, desc2, DialogModes.NO);
}

 

 

 

Kukurykus
Legend
May 11, 2021
runMenuItem(stringIDToTypeID('placedLayerResetTransforms'))
Legend
May 13, 2021
quote
runMenuItem(stringIDToTypeID('placedLayerResetTransforms'))

By @Kukurykus

Interesting. But does not work in 2020.

Kukurykus
Legend
May 13, 2021

I don't know when it was implemented, but probably it's something quite new. Try not by ran item, but traditional way, however I think that will fail too if I guess you don't have it in panel.