0
$\begingroup$

How to change the aspect ratio of an image while maintaining its area? I would like to know the math behind it because I can't make any sense of it.

Example: image with $h = 128$, $w = 128$, area $= 16384$, ratio $= 1:1$.

When ratio is $1:2$, it becomes $h = 90.51$, $w = 181.02$, area $= 16384.1202$.

How to achieve this mathematically?

$\endgroup$
1
$\begingroup$

Suppose that the area is $A = hw$ and we want $A$ (the area) to be held fixed. Then since $h= A/w$ and $w = A/h$, the aspect ratio $r = h/w$ will be given by $r = A/w^2 = h^2/A$.

In other words, if your area is fixed, then the aspect ratio is proportional to the square of the height and inversely proportional to the square of the width. Also, the height and width are inversely proportional to each other.

$\endgroup$

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.