ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Source text to Image size and resolution relative to scale

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Siddhant Mehra
Source text to Image size and resolution relative to scale
on Nov 19, 2017 at 11:15:50 pm

I want to create a Text Layer that controls Image Size, I want so that the user can type the desired number in the text layer and it would reflect on the scale property.
I want the numbers to be relative to the size of 1920x1080 resolution being 100% on the scale property and 0x0, being 0% on the scale property.
I suppose at 50% it should be 1280x720.

Is this possible at all?


Return to posts index

Dan Ebberts
Re: Source text to Image size and resolution relative to scale
on Nov 19, 2017 at 11:58:52 pm

If your image is 1920x1080, this would probably be the simplest:

s = parseFloat(thisComp.layer("Text Layer").text.sourceText);
[s,s]

(although 50% would correspond to 960x540 in that case). If you want 100% to be 1920x1080 no matter what the original size is, that would be more like this:

s = parseFloat(thisComp.layer("Text Layer").text.sourceText);
[1920/width,1080/height]*s


Dan



Return to posts index

Siddhant Mehra
Re: Source text to Image size and resolution relative to scale
on Nov 20, 2017 at 12:35:49 am

Hi Dan,

Thanks for the quick reply.

The expressions seems to be working quite well, solves the problem of being able to type only numbers in the source text, however as of now this expression makes it so that when i type 100 it actually scales it to a 100% and when i type 1920 it scales it to 1920% uniformly, would you suggest i use the same expression on two different text layers separating x and y values? Also, i was actually trying to achieve the opposite of this, when i type 1920 it actually scales the image to a 100%.
Similarly on Y axis when i type 1080 it scales it to a 100%.

Sid


Return to posts index


Dan Ebberts
Re: Source text to Image size and resolution relative to scale
on Nov 20, 2017 at 12:43:53 am

More like this then:

x = parseFloat(thisComp.layer("X").text.sourceText);
y = parseFloat(thisComp.layer("Y").text.sourceText);
[x/1920,y/1080]*100;


Dan



Return to posts index

Siddhant Mehra
Re: Source text to Image size and resolution relative to scale
on Nov 20, 2017 at 12:49:48 am

Worked like a charm, you're a god.

Thanks a lot!

Sid


Return to posts index

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