Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Source text to Image size and resolution relative to scale

  • Source text to Image size and resolution relative to scale

    Posted by Siddhant Mehra on November 19, 2017 at 11:15 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 1920×1080 resolution being 100% on the scale property and 0x0, being 0% on the scale property.
    I suppose at 50% it should be 1280×720.

    Is this possible at all?

    Siddhant Mehra replied 8 years, 9 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    November 19, 2017 at 11:58 pm

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

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

    (although 50% would correspond to 960×540 in that case). If you want 100% to be 1920×1080 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

  • Siddhant Mehra

    November 20, 2017 at 12:35 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

  • Dan Ebberts

    November 20, 2017 at 12:43 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

  • Siddhant Mehra

    November 20, 2017 at 12:49 am

    Worked like a charm, you’re a god.

    Thanks a lot!

    Sid

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