Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Scale rotated layer to fit comp size

  • Scale rotated layer to fit comp size

  • Aris Melachroinos

    April 5, 2021 at 2:08 pm

    Is there an easy way of calculating the scaling of a layer in order to fit the composition size, even if that layer is rotated? So something similar to the photoshop crop tool, where as you rotate the layer, it scales to fit the canvas.

    Lets say I have a 1920×1080 comp and a layer the same size, with the anchor point in the middle. When I rotate the layer 10 degrees, I can see the layer cannot fit the comp anymore.
    Is there an expression I can add the the scale property of the layer so that it fits automatically the composition?

  • Dan Ebberts

    April 5, 2021 at 4:19 pm

    Something like this maybe:

    a = degreesToRadians(rotation);

    s = Math.abs(Math.sin(a));

    c = Math.abs(Math.cos(a));

    w = width*c + height*s;

    h = width*s + height*c;


  • Aris Melachroinos

    April 5, 2021 at 4:32 pm

    Thank you a lot for your answer.
    Modifying the last line from [100,100]/Math… to [100,100]*Math… does exactly what I want.

    Do you happen to have any link so I can read about this calculation to understand it a bit better?

  • Trent Armstrong

    April 5, 2021 at 5:53 pm

    I am on board with Aris here, Dan. This would be great for one of your explanations with notes on the expression!

    Such a simple and elegant solution!!!

Viewing 1 - 4 of 4 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy