1

You can right click on a scale, hit Edit, and then enter scale in Pixels, inches , % of Comp, of source....

I would like to set the scale in pixels. How can set the units using expressions?

I tried returning ["200px","200px"], but that is an error.

2

The size in pixels is easily computed as the source's original dimensions multiplied by the scale. Or in other words

p = d × s

where p=pixel dimensions required, d=source dimensions, s=scale.

So to set the scale so that it takes a given source and makes it conform to a desired dimensions:

s = p / d

In an expression on the scale property you'd use

var p = [123, 456]; / desired output dimension
[ p[0] / width, p[1] / height ] * 100; // the *100 is because scale is a percentage

To be really fancy you could repurpose the scale value input so that it controlled the pixel dimensions. This means if you want the layer's dimension to be [123,456] you'd just dial it in in the scale control:

var d = value; //returns the pre-expression value of the property
[ p[0] / width, p[1] / height ] * 100

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.