-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrei_scaleComptoSelection.js
More file actions
37 lines (25 loc) · 1.09 KB
/
rei_scaleComptoSelection.js
File metadata and controls
37 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2023 Konstantin Reinhart. All rights reserved.
//
// Name: rei_scaleComptoSelection
// Version: 1.0
//
// Description:
// This script scales the current composition to the size of its selected layer
"use strict";
function scaleComptoSelection() {
var comp = app.project.activeItem;
var myLayer = comp.selectedLayers[0];
var mySize = {
width: myLayer.sourceRectAtTime(comp.time, true).width,
height: myLayer.sourceRectAtTime(comp.time, true).height
};
// Round number only allowed
comp.width = Math.round(mySize.width * myLayer.property('ADBE Transform Group').property('ADBE Scale').value[0] / 100);
comp.height = Math.round(mySize.height * myLayer.property('ADBE Transform Group').property('ADBE Scale').value[1] / 100);
// Set layer to comp center
var positionProperty = myLayer.property('ADBE Transform Group').property('ADBE Position');
positionProperty.setValue([comp.width/2, comp.height/2]);
}
app.beginUndoGroup("rei_ScaleComptoSelection");
scaleComptoSelection();
app.endUndoGroup();