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

Smartobject size to 100%

  • May 11, 2021
  • 3 replies
  • 7871 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.

JJMack
Community Expert
Community Expert
May 11, 2021

What size do you expect the object  place size to be in the document what is the place image file's Aspect Ratio compared to the document aspect ratio, what is the Image  file canvas size compared to the document canvas size. Photoshop is a Pixels editor. 

 

The Place Command has an interactive transform the user can use you scale the Place image. If you do not maintain the Image's Aspect Ration Transferring the image to fill the canvas the image will distort. If the Image has a different aspect ratio then the document some image content will be clipped off by the  documents canvas aspect ratio if you maintain the images aspect ration and it is different than the documents aspect ratio.

 

How do you want to handle aspect ratio miss matches.

JJMack
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.