使用 ExtendScript 将 compItem 转换为不同大小无法按预期工作

Transforming compItem to different sizes using ExtendScript doesn't work as expected

我在 AfterEffect 中有一个比例为 9:16 的 compItem。我正在编写一个脚本来自动将其转换为不同的 size/ratios。例如到16:9

如果我通过 AfterEffect 手动复制当前的 compItem 并更改像素大小(从 1080:1920 到 1920:1080),它会从顶部和底部平等地裁剪视频,这很好。

但是通过 ExtendScript,如果我复制并更新 widthheight,它只会从一侧(底部)裁剪视频。

以下是我写的脚本。任何见解都会有很大的帮助,谢谢。

var copies = {
    '4:5': [1080, 1350],
    '1:1': [1080, 1080],
    '16:9': [1920, 1080]
};

var currentComp = app.project.activeItem;

for (var i in copies) {
    var newCompItem = currentComp.duplicate();
    var width = copies[i][0];
    var height = copies[i][1];
    newCompItem.name = i;
    newCompItem.width = width;
    newCompItem.height = height;
};

可以通过以下步骤实现:

  1. 在当前合成中创建一个新的Null Object
  2. 将其设为合成中所有图层的父级。
  3. 编写一个脚本来改变构图的大小,如上所示。
  4. 居中Null Object

Null Object 居中会自动将图层居中,因为它是它们的父层。