ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Exprssion to scale layer to pixel size

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Riccardo Sinti
Exprssion to scale layer to pixel size
on Oct 6, 2015 at 4:43:34 pm

I have hundreds layers of differing sizes.
I need an expression that will scale the layer to a specific size, say
60px by 40px.
Thanks!


Return to posts index

Walter Soyka
Re: Exprssion to scale layer to pixel size
on Oct 6, 2015 at 4:59:57 pm

// set target dimensions in pixels
targetX = 60;
targetY = 40;

[targetX/width*100, targetY/height*100]

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Kalle Kannisto
Re: Exprssion to scale layer to pixel size
on Oct 6, 2015 at 5:01:57 pm

The code for scale would be:

rect=sourceRectAtTime(time, false);
rw = rect.width;
rh = rect.height;
finalWidth=60;
finalHeight=40;
[finalWidth/rw*100, finalHeight/rh*100]


You can replace the finalWidth and finalHeight settings with a slider if you want to be able to change them.

The scaling is not proportional with this expression, it will force the layers to be that size regardless of original dimensions. Layers will scale around their origin points.

You can put this expression into one layer scale property then copy and paste to all other layers.


Return to posts index


Walter Soyka
Re: Exprssion to scale layer to pixel size
on Oct 6, 2015 at 5:11:03 pm

Kalle's is better than mine. Mine won't work on vector/text layers, but his will.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Riccardo Sinti
Re: Exprssion to scale layer to pixel size
on Oct 7, 2015 at 8:48:35 pm

Thank you both!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]