Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Mask size(width x hight)via script

  • Mask size(width x hight)via script

    Posted by Julian Sixx on April 8, 2007 at 5:13 am

    Hi

    Is there a way to show me the exact dimension(width x hight) of a selected mask via script?

    For example:

    I’ve got a solid 720×576.I draw a rectangular mask.Now i’d like to see the dimension of this mask in numbers
    (200×125 i.e.)

    Tudor Baican replied 4 years, 2 months ago 6 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    April 8, 2007 at 6:46 am

    In scripting you do have access to mask info, but I don’t think there’s a way to detect which mask is selected.

    If you could specify the mask by number, it would be a bit of work, but you could set up a loop that would check each mask vertex for min x, min y, max x, and max y. It would then be easy to calculate the width and height of the bounding box.

    Then what would you want to do with that info?

    Dan

  • Julian Sixx

    April 8, 2007 at 5:02 pm

    Hi

    [Dan Ebberts] “Then what would you want to do with that info?”

    I think it might be very useful to know when creating Video walls for example.
    Well,it’s not the best example as you can make out the dimension of each video pretty easily without the script.

  • Pedro Amaral

    August 19, 2013 at 10:32 am

    Hi,

    So… 6 years later I come up with the same question:
    Is there any way to check mask dimensions (with or without scripts)? If not a squared mask, any way I can see the dimensions of its bounding box?

    I rarely use expressions or scripts so I wouldn’t know how to do this through a script…

    Isn’t this kind of a basic thing to be missing on such product?

    Thanks!

  • Xavier Gomez

    August 20, 2013 at 3:18 pm

    Hi.

    You can press the “Shape…” text in front of the MaskPath property of the mask. It will show the coordinates (left, top, right, bottom) of the mask bounding box that is used for the “Free Transformations”.

    However the term “bounding box” is a little bit abusive since it is not the actual bounding box of the mask, but that of its control polygon (the smallest rectangle containing all the vertices and the tangents extremities).
    If your mask is simple enough (eg one of the template shapes of AE, or if all the tangents are null) the two “bounding boxes” will coincide, otherwise the one displayed by AE is bigger (and not very useful…)

    Now if you need the info in real time for use in an expression, it is possible but quite complicated and very slow.

    Can we know what you need it for ?

    Xavier.

  • Pedro Amaral

    August 20, 2013 at 5:23 pm

    s there any way to check mask dimensions (with or without scripts)? If not a squared mask, any way I can see the dimensions of its bounding box?

    I rarely use expressions or scripts so I wouldn’t know how to do this through a script…

    Hi,

    Thank you very much for the quick reply.

    Well yes the “Shape…” property will show me the coordinates but like you said these values are not directly associated with the masks bounding box and therefore I will have to do the maths to get the Height and Width values.

    I am just looking for a quick way to check the dimensions of a selected mask (not even asking for a way to edit its dimensions by inserting values, that would be just awesome), something like looking at a solid’s properties (Cmd+Shift+Y) and having width and height displayed and editable.

    While creating a motion reel with animated wireframes for a mobile app, and as in early stages of the creative process I am making bits and pieces of the design directly in After Effects rather than going back and forth to Illustrator or Photoshop. I make everything with masks (not a big fan of Shape Layers) directly in AE and would be nice to have access to some more details and control over the masks I create.

    I’ve been patiently waiting to see Masks a little bit more improved and powerful for awhile now, it would be nice to see new (relevant) mask features on future AE versions.

    Thanks anyway!

  • Xavier Gomez

    August 20, 2013 at 7:08 pm

    Actually i’m writitng a script that does things like this. I started a week ago or so, it’s not finished and i was wondering if it would be of any use. The tools include ‘draw b.box’ (on a new mask), align masks (similar to align layers), fit masks to something else (layer or the bbox of another mask), scale(%)/resize(px), rotate, flip, move to specific location, etc. At the moment most ui buttons wont work but the box one does.

    If you think it can help you i can try to make some fast clean up and post the current version.

    Xavier.

  • Pedro Amaral

    August 20, 2013 at 9:18 pm

    Hi Xavier,

    I would gladly give it a go, but there’s no rush on this though.
    You should definitely write the script I am sure it will be extremely useful for a lot of people out there. If you’re willing to share it later on you should use AEScripts community or something like that once as I’m sure you’ll have a lot of support.

    I wish I had scripting knowledge, I’d be building my own tools within AE.. Just don’t know where to start.

    Good luck with the Script and thanks for all the help and attention.

  • Xavier Gomez

    August 21, 2013 at 11:09 am

    Hello,

    this is a draft version.
    Only few tools work and the code needs serious cleaning. Hopefully though, it can still help since the “box” tool is done: you can get the bounding box info by pressing the “?” button, or draw the bounding box on a new mask by pressing the “right arrow” button.
    Suggestions Welcome.

    Xavier.

    Unzip and drop the jsxbin + the icons folder in the ScriptUI Panels folder (not just Scripts, it won’t work). There is no debug yet in case the script cant’ find the icons. Also the script uses onClick events for Images: it works in Windows7/AE-CS5.5 but i’m not sure it does in all Platforms/AE versions.
    6433_maskbox.zip

  • Tom Savage

    July 24, 2020 at 2:27 pm

    Xavier did you ever finalize this script or have you seen anything similar. I’m looking to fit masks to something else [like a png or jpeg layer] (layer or the bbox of another mask), scale(%)/resize(px).

    I’m using the same animation for 100 different brands that all sell a similar product (soap) each soap is slightly different width but I have set them all to the same px height via an automation in photoshop to resize all the png images of soap to 1000px height by Variable width. I am programmatically going to swap out the png and the text for each of the 100 brands. The issue is that the mask width is not variable. I found this post where you mentioned the about via a script you wrote that could potentially set the mask to the width of the png layer.

    I also saw you posted the script in a below comment which I am going to dive in on but wanted to see first if you had updated it or if you knew of anything that exists to do this.

  • Tudor Baican

    February 14, 2022 at 2:00 am

    Hello Friends,

    I’m also looking to get the bounding box size of a mask.

    Anybody here how found an elegant solution/expression for this?

    Thanks

Page 1 of 2

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