Activity › Forums › Adobe After Effects › Scaling layers with expressions
-
Scaling layers with expressions
Posted by Razamataz on December 1, 2005 at 5:19 pmHello what i’m tyring to do is scale my layers to match the height of my composit whilst at the same time keeping the aspect ratio. All the images are different sizes and there are 1000’s of them.
ThanksBen Insler replied 20 years, 5 months ago 3 Members · 3 Replies -
3 Replies
-
Mylenium
December 1, 2005 at 6:17 pmTry this:
my_scale=thisComp.height/height*100;
[my_scale,my_scale]
Mylenium
[Pour Myl
-
Ben Insler
December 1, 2005 at 7:02 pmNice expression Mylenium, but here’s a little tweak because yours only works for images that are taller than they are wide (so images that are wider than they are tall will get cropped on the sides). I added a condition to check which is larger, the width or the height, and the expression scales to the larger of the two to fit the whole image. Also, if the scaling is occuring based on the width, it is automatically scaling based on the comp’s pixel aspect ratio. expression is below:
if(height>width) x=thisComp.height/height*100; else x=thisComp.width/width*(thisComp.pixelAspect*100);
[x,x]Hope that works.
-Ben -
Ben Insler
December 1, 2005 at 9:37 pmsorry… I thought about the expression again and realized that undesired cropping still could occur… I changed the condition so that rather than choosing the scaling method based on the longer width or height of the image, it compares the image’s width/height ratio to that of your comp. If the ratio is wider than your comp, it scales it down based on the width; if it’s taller it scales it down by the height. The expression is below.
if((width/height)<=((thisComp.width*thisComp.pixelAspect)/thisComp.height)) x=thisComp.height/height*100; else x=thisComp.width/width*(thisComp.pixelAspect*100); [x,x] -Ben
Reply to this Discussion! Login or Sign Up