Images Aspect Ratio

101 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.