2

I am working on a software 2D model where we need to work with aspect ratios. My boss gave us a formula which defines it as:

aspect ratio = height of image/ width of image

Now we are using a cropping library over this which has a different formula. For them:

aspect ratio = width of image/ height of image

I am very poor in math, being more of a designer guy. So my question is, which one is correct? Or are they both (based on context perhaps?).

Because of this difference in the formula, the image and the cropping overlay on top of it is mismatched. So I guess another question I have is, if I have an aspect ratio, is there any way I can pivot it to make landspaces into portraits or vice-versa?

Any help is very, very much appreciated!!

2 Answers2

2

Typically, an aspect ratio is defined as width/height.

To convert between the two formats, you need to take the reciprocal, which is done by dividing $1$ by the number. So if one format gives a ratio of $.75$, the ratio for the other format would be $\frac{1}{.75}\approx1.33$.

KSmarts
  • 3,364
  • That is really good!! So if I do have one calculated in the wrong way, there is a chance for me to get something that is close enough then in the pivoted way, right? – open_sourse Dec 19 '14 at 20:40
  • Also I am a bit surprised here - my boss is a geeky math guy, would there be any reason he used height/width instead of the other way around? – open_sourse Dec 19 '14 at 20:41
  • @open_sourse Well, the order that things are typically given varies depending on application and circumstance. For example, an $n\times m$ matrix is $n$ rows high and $m$ columns wide--height comes first in this case. This makes it easy just to get mixed up, which is probably what happened. – KSmarts Dec 19 '14 at 20:48
  • I guess you are right..we are working on a 2D space where the width is 2x the size of the height. Perhaps that is the reason...? – open_sourse Dec 19 '14 at 20:49
  • Genius! Thank you very much. I is so useful to switch between the two formats. – Marian07 Jan 10 '20 at 16:21
1

This is the correct solution

aspect ratio = original width ÷ original height

because

Explanation:

The aspect ratio of an image describes the proportional relationship between its width and its height.

It is commonly expressed as two numbers separated by a colon, as in 16:9. For an x:y aspect ratio, no matter how big or small the image is, if the width is divided into x units of equal length and the height is measured using this same length unit, the height will be measured to be y units.