Last active
September 29, 2020 03:49
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modified to take the scale of the first layer into account