How to get SmartObject transform properties?

SmartObjects have an option to “Convert to Layers” which is amazing, but if the SmartObject was transformed ( Scaled, moved around ) it will give you a message that the transform applied on the Smart Object will not be retained:

image

Is it possible to read this transformation of the Smart Object? I have a plugin that when It converts to layers it would need to retain the transformation. Any ideas how I could hack this behaviour?

Bests,

You can access smart object transform data via getting the ‘smartObjectMore’ data through batchPlay. Check out this topic: Access SmartObject transform properties?

1 Like

Years ago I wrote ExtendScript and it has the option to do that. I take layer comps, transparency, and masks into consideration as well as scaling layer effects. Layer effects can be scaled only proportionally meaning 1:1 ratio in width and height. Also it will not change smart filters. https://www.mightyplugins.cc/magic-scripts

2 Likes

I remember really well this script, I used to use it when I started to learn to program it helped me a lot to understand fundamentals! And then Adobe liked it so much that included that feature within PS! Seems the solution from @dotproduct did the job I was looking for!

Thank you very much man, that post helped me to find the solution I was looking for, I also created a function to get the scale from points, I’m adding that to that post in case someone finds it helpful!:

   function getScaleFromPoints(points, fullSize) {
        const A = points.upperLeft;
        const B = points.upperRight;
        const C = points.lowerLeft;

        const w = distance([A.x, A.y], [B.x, B.y]);
        const h = distance([A.x, A.y], [C.x, C.y]);

        const fullWidth = fullSize.width;
        const fullHeight = fullSize.height;

        const wP = (w * 100) / fullWidth;
        const hP = (h * 100) / fullHeight;

        return {
          width: wP,
          height: hP
        }

        function distance(a, b) {
          var AB = [b[0] - a[0], b[1] - a[1]];
          return Math.sqrt(AB[0] * AB[0] + AB[1] * AB[1]);
        }
      }
1 Like

If you use rectangular to quadrilateral transformation… you don’t need to calculate scale. Instead, you will just define the corner coordinates of the target transformation.

2 Likes

I don’t know how to do that. How can I do that?