Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Resize a box depending on the number of characters?

  • Resize a box depending on the number of characters?

    Posted by David Cabestany on June 13, 2014 at 4:46 pm

    I’m making a set of name locations for a map, like 65 of them, they are names of places, like Philippines, Burma, Oahu, etc.

    They all need to do the same animation, so I precomped the text and the box surrounding it and added an expression to the text that changes it by just changing the name of the comp.

    Can anyone help me to figure out an expression that can resize the width of the box depending on how many characters are in the word? Naturally Philippines needs a wider box than Oahu and so on, if I can automate that too it would be a huge timesaver.

    Thanks!

    David Cabestany replied 12 years, 2 months ago 2 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    June 13, 2014 at 7:31 pm

    you don’t need an expression, just creative use of effects…

    on your text layer:

    • add the fast blur effect and set blur to 5 (this is arbitrary, you’ll adjust it later to set the amount of padding for the box).
    • then add the shift channels effect setting the take alpha to full on.
    • add the fill effect and pick a color for the text box.
    • then add cc composite to put the text back in the box.

    if you needed to adjust the transparency of the box, addjust the opacity of the fill effect and uncheck the ‘rgb onky’ option in the cc composite effect.

    one drawback is if you are using upper and lower case letter ascenders and descenders will effect the height of the box, and you may not want that.

    in those cases, i’ll usually duplicate the fast blur and set one to blur horizontal, the other to blur vertical, then increase the vertical blur amount. then add 2 linear wipe effects, one to crop off the top edge and the other to crop off the bottom so that the height will remain consistent.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • David Cabestany

    June 13, 2014 at 7:54 pm

    Wow, this is brilliant man, thanks a lot. I have never used shift channels and cc composite before.
    It works great, but I have a white outline on the box, that’s why I was using a shape layer before, all i need to figure out is how to bting back that stroke without having to do it manually.

    Thanks a lot again!

  • David Cabestany

    June 13, 2014 at 8:08 pm

    In case anyone find this useful I added the modifiable outline by duplicating the layer with all the effects Kevin mentioned except cc composite and I added a find edges effect at the bottom of the stack, then I inverted it. Works great.

    Thanks!

  • Kevin Camp

    June 13, 2014 at 9:01 pm

    that’s a good way to do the outline. i’ve also used layer styles>stroke, but that too usually requires the box to be a separate layer from the text, otherwise you are limited to stroke the same color as the text and stroke position set to inside…

    the text box trick is petty cool, and since the effects can be stacked on a single layer, it can be saved as a preset to easily recall it when you needed it.

    i should also have mentioned that if you needed rounded corners you can add simple choker after the shift channels effect. it works pretty well unless you need really round corners… when you push choker too far it starts looking ‘bulgy’.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • David Cabestany

    June 13, 2014 at 10:37 pm

    Thanks man, you saved my weekend!!

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