Frequently an image or video asset / footage will be placed into a composition with a specific scaling or size to fit the design. But what happens when this asset is enabled for dynamic and the size changes?
The problem is that when different sized images and videos are swapped in, they may not look good in the design.
To solve this, you can use expressions to automatically scale your assets to fit the needs of the design.
Assume you have the following structure where the top-level composition has been positioned and scaled to the size you want for the design.
Comp 1 - parent container in design
-- Comp 2 - pre-comp container for the dynamic asset
-- -- Layer 1 - dynamic footage asset
The expression will be put on Comp 2’s scale transform to adjust the composition’s size in response to the size of the dynamic asset.
The expression gets the height of the parent Comp 1 and the height of the dynamic footage Layer 1, calculates the ratio, and uses this to set the scaling on the Comp 2.
w = comp("Comp_1").height ;
v_w = comp("Comp_2").layer("Layer_1").height;
r = w/v_w*100;
To automatically resize assets:
- Customize the highlighted portions of the expression above to use composition and layer names from your design
- Open up the scale transform attribute for the container composition and copy paste the updated expression