# How to determine width and height of outer rectangle when it is scalled to an inner rectangle

I have a rectangle with more than 800 width and 600 height. It can be 1000 x 600, 2000 x 1000 and etc. I want to scale it to 800 x 600. I want to determine which one matches first, the height or the width and also get the other value that didn't meet first.

|                |
|  |800x600   |  |
|  |inners rec|  |
|                |outer rectangle(1000 x 1000) if I resize which one will hit the boundaries of the inner rectangle left and right or top and bottom.


updated

I used the term square When it should be rectangle.

• Look at the ratios of width to width or height to height. Pick the larger or smaller one, depending on your numerator and denominator. – Michael Burr Sep 13 '17 at 14:07
• Your comment ins an answer in its own right: "Look at the ratios of width to width or height to height. Pick the larger or smaller one". – Diego Alves Sep 13 '17 at 15:39

Take the ratio in each axis and use the smaller one. So if you start with $2000 \times 1000$ the horizontal is $\frac {800}{2000}=0.4$, the vertial is $\frac {600}{1000}=0.6$. So you scale by a factor $0.4$ and the vertical is $0.4 \cdot 1000=400$. These are rectangles, not squares.