Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression to link scrolling numbers to another layer’s scale

  • Expression to link scrolling numbers to another layer’s scale

    Posted by Willie Frazier on April 6, 2012 at 4:06 pm

    Hello all,

    So, I am fairly new to expressions, and was just given a task for which I am going to need one. I am to take a picture and scale it down, and under the picture there should be resolution sizes, like 1920×1280. As the image scales down the numbers should dynamically change down until to new resolution is hit. There will be at least 2 such hits, possible more.

    Thanks in advance for any help,

    -Will

    Walter Soyka replied 14 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Walter Soyka

    April 6, 2012 at 4:22 pm

    There’s a dedicated After Effects expressions forum [link], but I’ll give it a go here.

    Create a new text layer, through in some dummy text, and position and format it as you like. Click the disclosure triangle next to the text layer in the timeline panel, then alt-click the Source Text stopwatch. Enter the following:

    i = thisComp.layer("image.jpg");
    w = Math.floor(i.width*i.transform.scale[0]/100);
    h = Math.floor(i.height*i.transform.scale[1]/100);
    w + "x" + h

    Of course, change “image.jpg” to match the name of your image layer.

    Translated to English:

    • Consider “i” shorthand for the image.jpg layer
    • Let “w” equal the width of the image.jpg layer, times its scale, divided by 100. Lob off anything after the decimal point so I get a whole number of pixels.
    • Likewise for “h” and height.
    • Return a text string of the width, the letter x, then the height.

    Please note that this will break if you use parenting to affect the scale.

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

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