Copy link to clipboard
Copied
I have a script to resize my compositions. But how would I make all the layers in the composition fit that composition size by using a script?
Getting the "visible bounds" can be very tricky.
There is the method AVLayer.sourceRectAtTime() which gives you those bounds in layer space and with
AVLayer.sourcePointToComp() you can convert those four corners to comp space.
However, this only takes layer transforms into account. If you have effects changing the content (like a corner pin or some warp effects) the actual visible layer could have very different visible bounds again.
Copy link to clipboard
Copied
There is any number of comp resizer scripts on AEScripts.com and of course fitting layers may be as trivial as invoking one of the Fit... options from the layer menu.
Mylenium
Copy link to clipboard
Copied
If you want to program it yourself, an easy solution would be to create a new null null in the center of the comp, parent all layers that have no parent to it and then scaling the null as needed.
Of course, that does not deal with different aspect ratios, yet. If you want to fit 16:9 content into a square comp, for example, the question where which part needs to be placed (and scaled) is a creative decision that cannot be automated easily.
Copy link to clipboard
Copied
Thank you. I think all I need is to get for each layer something similar to "visibleBounds" that are available in Illustrator (but I don't find in the AE scripting documentation). Because with that I can find the minX, maxX, minY and maxY for the layers and calculate the width and height and then set the comp size to that.
Do you know how to get the coordinates for a layer in AE?
var theComp = app.project.activeItem;
for (var i = 1; i <= theComp.numLayers; i++) {
var curLayer = theComp.layer(i);
$.writeln(curLayer) //here I would need to call a method on curLayer similar to visibleBounds in Illustrator to get the coordinates for this layer
}
Copy link to clipboard
Copied
Getting the "visible bounds" can be very tricky.
There is the method AVLayer.sourceRectAtTime() which gives you those bounds in layer space and with
AVLayer.sourcePointToComp() you can convert those four corners to comp space.
However, this only takes layer transforms into account. If you have effects changing the content (like a corner pin or some warp effects) the actual visible layer could have very different visible bounds again.
Copy link to clipboard
Copied
All of the resizing scripts that I have, including the Scale Comp script that comes with AE in the File/Scripts/Demo Pallet menu properly resize all layers in a comp. What exactly are you having problems with? I don't create very many compositions where every layer is the same size as the comp and I can't imagine wanting to do so. I do a fair amount of work in 4K and 6K comps that are destined for HD and 2K, and even social media frame sizes, but I seldom resize the comps. In a lot of cases, I'll render a mezzanine format Production Master/DI and then use the Media Encoder or Premiere Pro to take that 4K or 6K comp to different frame sizes for distribution. I do that because many of my effects and motion graphics comps can take well over a minute a frame to render. Resizing a video is always faster than rendering a comp again.
Copy link to clipboard
Copied
Thanks for that insight. In my case I am exporting a lottie file from each composition and if there is extra space around the layers it results in extra space around the artwork in the lottie file. It looks like extra padding on the lottie file. When the composition has the same size as the layers, there is no padding visible when adding the lottie file to iOS at least.
Copy link to clipboard
Copied
Does it have to be a script?
Would using one of the Fit to Comp options work?
Any layer selected that the time you do this will be scaled to fit.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now