Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can I resize, with expressions, a picture accordling to the comp size?

  • Can I resize, with expressions, a picture accordling to the comp size?

    Posted by Fred Lobo on September 2, 2009 at 8:15 pm

    So, it should have an automatic way to do this. I have a bunch of pictures wich will change everyday. But each one has a different size, so is it possible to make an expression to drive the scale? Making the pictures always fit an established height.
    Thanks in advance,
    Fred

    Djame Goldston replied 15 years, 2 months ago 4 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    September 2, 2009 at 8:38 pm

    Do you just need the height to match the comp height? If so, this should work:

    s = (thisComp.height/height)*100;
    [s,s]

    If you need it to match either the comp width or the comp height (depending on which one doesn’t cause clipping)and have to deal with the possibility of the image not having the same pixel aspect ratio as the comp, there’s more work to do.

    Dan

  • Robert Trione

    September 11, 2009 at 6:16 pm

    Dan,

    How would I write an expression for particular that uses the comp size to determine the box Emitter size? I’m trying to make a better particular preset. At the moment I have to manually change the emitter size. Thanks.

  • Dan Ebberts

    September 12, 2009 at 1:57 am

    Couldn’t you just set the Emmiter Size X to thisComp.width and Emitter Size Y to thisComp.height? Or are you after something more complex?

    Dan

  • Robert Trione

    September 12, 2009 at 12:51 pm

    I feel silly now. No, that sounds perfect. Thank you.

  • Djame Goldston

    February 24, 2011 at 6:42 pm

    This thread is old, but thought I’d add my 2 bits for google’s sake… and for mine if I forget how to write the damn expression. lol.

    I use this for NTSC output. Comp of unknown size and image of unknown size. Aspect compensation width only (NTSC) and this assumes square pixel images though I would think you could modify to check and compensate… it would be a pain for legacy aspects. You could also pull the “p” and fix the width (“s”1) by “* 90;”.

    w = thisLayer.width;
    h = thisLayer.height;

    compW = thisComp.width;
    compH = thisComp.height;

    p = thisComp.pixelAspect;

    s1 = (compW / w ) * 100;
    s2 = (compH / h ) * 100;

    if ( s1 > s2 ){ //test size difference
    [ s2 , s2 ]
    }else{
    [ s1 * p , s1 * p ]
    }

  • Djame Goldston

    February 25, 2011 at 3:56 pm

    Oops, I left off the aspect correction for the height. See below…

    w = thisLayer.width;
    h = thisLayer.height;

    compW = thisComp.width;
    compH = thisComp.height;

    p = thisComp.pixelAspect;

    s1 = (compW / w ) * 100;
    s2 = (compH / h ) * 100;

    if ( s1 > s2 ){ //test size difference
    [ s2 * p , s2 * p ]
    }else{
    [ s1 * p , s1 * p ]
    }

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