Skip to content

Instantly share code, notes, and snippets.

@Airyzz
Last active September 29, 2020 03:49
Show Gist options
  • Save Airyzz/cce57080b416dc6a40f2e04150cd85b8 to your computer and use it in GitHub Desktop.
Save Airyzz/cce57080b416dc6a40f2e04150cd85b8 to your computer and use it in GitHub Desktop.
Script to resize all selected layers to the size of the first selected layer
app.activeViewer.setActive();
var activeComp = app.project.activeItem;
var layers = app.project.activeItem.selectedLayers;
var time = app.project.activeItem.time
if(layers.length > 1)
{
target = layers[0].sourceRectAtTime(t = time, includeExtents = true)
target_scale_w = layers[0].scale.value[0] / 100;
target_scale_h = layers[0].scale.value[1] / 100;
for(var i = 0; i < layers.length; i++){
size = layers[i].sourceRectAtTime(t = time, includeExtents = true)
width_scale = ((target.width * target_scale_w) / size.width) * 100
height_scale = ((target.height * target_scale_h) / size.height) * 100
var scale = layers[i].scale.value;
scale[0] = width_scale
scale[1] = height_scale
layers[i].scale.setValue(scale)
}
}
else
{
alert("Error: Script requires two or more layers selected.")
}
@Airyzz
Copy link
Author

Airyzz commented Sep 29, 2020

modified to take the scale of the first layer into account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment