# Math Help - I forgot everything since highschool. Need help with this simple equation

1. ## I forgot everything since highschool. Need help with this simple equation

Hello,

I have a dynamic picture that could be any arbitrary size. I also have a picture frame, that is 567pixels wide and 360pixels high (pixels can be inches, or any other measurement. I chose pixels for this scenario). The dynamic picture needs to fit within the frame, but at the same time, fit within it at its proper scale. So if the dyanmic picture is 1000pixels x 1000pixels, for it to properly fit to scale in this scenario, it would have to be 360pixels wide x 360pixels high (can't be more than 360 high cause it has to fit in the frame). If I decided to make it 567 x 360 (to fit the frame), then obviously the picture would be stretched, which is a no go.

Can anybody help me with this simple equation?
Thanks!

2. define:
$x_p,y_p$ the horizontal and vertical sizes of your picture
$x_f,y_f$ the horizontal and vertical sizes of your frame
$s$ a scale factor we will apply to your picture to make it fit in the frame.

Lets find a scale factor s to apply to your picture to make it fit in the frame

suppose you wanted to change the height so that it would just fit in the vertical dimension;
$s_y = \frac{y_f}{y_p}$

now suppose you you wanted to change the width so that it would just fit in the horizontal dimension
$s_y = \frac{x_f}{x_p}$

We want it to fit in both dimensions, and apply the same factor to height and width
$s = min(s_x,s_y,1) = min \left( \frac{x_f}{x_p}, \frac{y_f}{y_p},1 \right)$

Note: The ",1" will prevent the image being blown up to fill the frame if it is smaller than both dimensions of the frame

The final dimensions of your picture are
$sx_p \times sy_p$

3. Interesting! Thanks for the help! I am going to try to make this work now.