2

If I have a video of size:

 width: 640
 height: 480

and a screen of size:

 width: 1280
 height: 720

what is the equation to find the max width and height I can stretch the video too and keep its ratio.

I can calculate the ratio like:

 ratio = width / height

 video ratio: 1.3

 screen ratio: 1.7

that's about as far as I can work out :-(

Blundell
  • 123

2 Answers2

2

Since the ratio of the widths is 2 and the ratio of the heights is 1.5, you can stretch the video by a factor of $\min(1.5,2)=1.5$ and it will still fit on the screen. If you scale it up by a larger factor it will be too large in the vertical dimension.

Eckhard
  • 7,705
2

Divide the corresponding measurements by each other: screen width by video width, screen height by video height. Then take the smaller of the two ratios, and that's the amount you can stretch the video by.

In this example, we have $$\frac{\text{screen width}}{\text{video width}} = \frac{1280}{640} = 2$$ $$\frac{\text{screen height}}{\text{video height}} = \frac{720}{480} = 1.5$$ So you can stretch the video by a factor of $1.5$, making it $960\times720.$

Jonathan Christensen
  • 3,870
  • 15
  • 21
  • This is assuming the screenwidth is always greater than the video width? – Blundell Jan 12 '13 at 20:53
  • If the screen size is larger than the video size (both height and width) you'll end up with a number larger than 1; the method still works if the screen is smaller in one or both dimensions, you'll just end up with a number smaller than 1 to multiply by. – Jonathan Christensen Jan 12 '13 at 21:28