# Images Aspect Ratio

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?

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$$.