luis_mendes wrote:
My images vary in width and height. I would like them to be maintain their aspect ratio, while fitting the shortest side (width or height) of the smart object it is replacing (which is a square).
I think there is a basic problem here with your understanding of how smart object layers work.
The layer embedded object what ever it may be. Has pixels rendered for it for the smart objects layers content and there is and associated transform for the layer. These pixels are protected from change you can not directly alter them. When you change the layer size you do it by altering the layers transform. You can also attach smart filters to the layers content and mask the layer. You can not use tool on the layers that alter pixels no paint, erase, lines etc. If you use layer duplicate to dupe the layer the dup layer shares the embedded object. You can transform layers that share an embedded object to form a picture package the changing each layers associated transform. To different areas over the documents canvas. When you replace the shared embedded smart object all the layers that share the object change. The associated transforms are not changed. If you do not replace the current embedded object with an object that is the same size the smart object layers associated transforms will not work the way you would expect then to work. For the were set for a different size object.
If you know the output area size and its location you should be able to script what you want. I would think after you replace the embedded content. You could set the layers transform to 100% width and 100% height get the layers bounds and calculate the required transform. for the output area. I do something like that in my collage package. However I resize the image to fill the output area and mask off any excess image so the image get aspect ratio of the output area and looks like a centered crop.
However from the example template in this thread there look to be a perspective transform involved which may have some rotation. I have never tried to program in the ability to handle rotation and prospective placement of images. I just tweak the populated collage manually if an image or two need that type of transform.