Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Resize a layer according to the image size

  • Resize a layer according to the image size

    Posted by Jeff Horowitz on May 8, 2014 at 7:42 pm

    So I have two layers: 1) is a solid. 2) is an image.

    I want to add an expression to the scale property of the solid to tell it to resize according to the size of the image.

    The whole comp is 1920×1080
    The solid is 1920×1080 & scaled down to 78.0,80.0%
    The image.png is 1920×1080 & scaled down to 75.0,75.0%

    Here’s the example:

    Now, if I replace that 1920×1080 image with an image that is 400×533, I want the white solid to resize to fit the dimensions of the new image.

    Here’s the example:

    Jeff Horowitz replied 12 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 8, 2014 at 9:09 pm

    This assumes that the solid is directly below the image. Adjust the variable “border” to adjust the border width.

    L = thisComp.layer(index-1);
    border = 20;
    w = L.width*L.scale[0]/100 + border*2;
    h = L.height*L.scale[1]/100 + border*2;
    [w*100/width,h*100/height]

    Dan

  • Jeff Horowitz

    May 9, 2014 at 12:04 am

    That worked perfectly…thanks

    JAH

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