Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Is there any script to resize comp adding pixels over original value?

  • Is there any script to resize comp adding pixels over original value?

  • Javier Burgos

    August 21, 2020 at 6:39 pm

    Hi everyone

    I’m working on a project with a lot of photoshop layers (I import the file in retain layer size way).
    I precompose every layer (leave all attributes) and then I need to increase de composition size 300px width and 100px height.
    The result is the original composition oversized from the precomposed layer.
    I would like to do this with a lot of compositions at a time.
    My question: Is there any script to resize multiple compositions adding pixels over the original value?
    Every comp has its own size so I can’t set the number exactly one by one. I would like to increase the original value whit an specific number of pixels

    Thanks!!

    (sorry if there is any mistake in my english)

    javiburgos.com

  • Scott McGee

    August 24, 2020 at 4:11 pm

    Simple answer is yes.

    Not sure if you are wanting to change 100 in one click or as you are importing the files.

    but I don’t know if there is a free or purchase script to do the job, but if you are comfortable with scripting. Essentially this is it

    var comp = app.project.activeItem;
    comp.width = 1920;
    comp.height = 1080;

    You can adapt to take the original size

    var comp = app.project.activeItem;
    var origCompSize = [comp.width,comp.height];

    var newCompSize = [origCompSize[1] + 300, origCompSize[0]+100];

    comp.width = newCompSize[0];
    comp.height = newCompSize[1];

    That will change the size of the active comp open in AE, but if you stick that into a loop of selected comps (little more complex, not that much) in the project window that will resize all the comps based on their size and add 300px width and 100px height.

  • Scott McGee

    August 24, 2020 at 4:36 pm

    That was quicker than I thought it would be to write.

    var mySelectedItems = [];
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i).selected)
    mySelectedItems[mySelectedItems.length] = app.project.item(i);
    }

    for (var j = 0; j < mySelectedItems.length; j++) {
    var comp = app.project.selection[j];
    var origCompSize = [comp.width,comp.height];
    var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];
    comp.width = newCompSize[0];
    comp.height = newCompSize[1];
    }

    Any comps you select in the project window will be increased by 300 width and 100 height.

  • Javier Burgos

    September 4, 2020 at 7:47 am

    Wow Scott!, It’s works fine
    I see it increases de size from 0,0 (position coordinates). Is there any way to leave the layer in it original position, in the middle of the comp? Maybe oversize from layer anchor point?

    thank you so much!!

    javiburgos.com

  • Scott McGee

    September 9, 2020 at 8:13 am

    As long are you are changing the anchor point when it’s placed into the comp in the first place.

    This should work 🙂

    var mySelectedItems = [];

    for (var i = 1; i <= app.project.numItems; i++){

    if (app.project.item(i).selected)

    mySelectedItems[mySelectedItems.length] = app.project.item(i);

    }

    for (var j = 0; j < mySelectedItems.length; j++) {

    var comp = app.project.selection[j];

    var origCompSize = [comp.width,comp.height];

    var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];

    comp.width = newCompSize[0];

    comp.height = newCompSize[1];

    comp.layer(1).property(“Position”).setValue([comp.width/2,comp.height/2]);

    }

  • Javier Burgos

    September 15, 2020 at 9:28 am

    Hi Scott,

    After Effects displays an error message: “Unable to execute script at line 23. Syntax error”

    I can’t see the error…

  • Scott McGee

    September 15, 2020 at 4:56 pm

    It’s because I copied and pasted and my “” changed to ““…And yes that does matter. Now if you copy and paste below. It will work. Slight Smile

    var mySelectedItems = [];

    for (var i = 1; i <= app.project.numItems; i++){

    if (app.project.item(i).selected)

    mySelectedItems[mySelectedItems.length] = app.project.item(i);

    }

    for (var j = 0; j < mySelectedItems.length; j++) {

    var comp = app.project.selection[j];

    var origCompSize = [comp.width,comp.height];

    var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];

    comp.width = newCompSize[0];

    comp.height = newCompSize[1];

    comp.layer(1).property(“Position”).setValue([comp.width/2,comp.height/2]);

    }

Viewing 1 - 7 of 7 posts

Log in to reply.

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