ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Fred Lobo
Can I resize, with expressions, a picture accordling to the comp size?
on Sep 2, 2009 at 8:15:33 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


Return to posts index

Dan Ebberts
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Sep 2, 2009 at 8:38:18 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



Return to posts index

robert trione
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Sep 11, 2009 at 6:16:40 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.



Return to posts index


Dan Ebberts
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Sep 12, 2009 at 1:57:31 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



Return to posts index

robert trione
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Sep 12, 2009 at 12:51:48 pm

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



Return to posts index

Djame Goldston
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Feb 24, 2011 at 6:42:30 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 ]
}


Return to posts index


Djame Goldston
Re: Can I resize, with expressions, a picture accordling to the comp size?
on Feb 25, 2011 at 3:56:11 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 ]
}


Return to posts index

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