Wednesday, March 26, 2014

AFTER EFFECTS: Resize All Comps JSX Script

As part of the Magic Lantern raw workflow I'm slowly developing, I needed to resize all the footage comps to 1920x1080.  For months I was doing it manually like a chump, highlighting each comp, hitting CTRL + K, and typing in "1920" into the width field.

NO LONGER.

Thanks to a Google search and a forum post by Dan Ebbert of motionscript.com, I now use a script to automate this task.  I'm still working on the code to fit the contents to the new comp size, but it at least eliminates the tedious task of changing the comp sizes.

For those that have never ran an AE script before, you go under FILE > Scripts > Run Script File...  But before that, you must create the JSX script file by opening the script editor.  Once the script editor is opened, type or paste this into it:

for (var i = 1; i <= app.project.numItems; i++)
{  
    if (app.project.item(i) instanceof CompItem)
        {
        app.project.item(i).width = 1920;
        app.project.item(i).height = 1080;
        }
}

Once that's done, save it.  Run the script and it'll change all the existing comps inside your project bin to the designated "width" and "height" values.  You can change those numbers to suit your projects.

The difference that I've noticed is that the comp doesn't scale from the center, but from the upper left hand corner.  Not a big deal for me since I need the contents of the comp to fill the full comp size, but definitely something to note.

For the time being, I'm using the good ol' CTRL+ALT+F command to fit the footage to the new 1920x1080 comp size.  I'll update this post once I figure out how to resize to comp using the script.