After effects, make background rectangle the same size as text
21. 1. 2026If my text layer is named ‘text’, then this js will be in the background rectangle ‘Size’:
// Define the text layer to follow
var textLayer = thisComp.layer("saša janez maechtig"); // Replace with your text layer name
// Get the size of the text
var textRect = textLayer.sourceRectAtTime(time, false);
// Define padding
var paddingX = 10; // Width padding
var paddingY = 30; // Height padding
// Calculate final size
[textRect.width + paddingX, textRect.height + paddingY]