title: math/algorithm Fit image to screen retain aspect ratio
body: <p>I need help with math / algorithm  to take an image of known size and fit to one of two screen dimensions:</p>
  <p>720 x 480 or 1280 x 1024.</p>
  <p>The image dimensions are coming from an XML file, however those dimensions are the web dimensions, I also get a selection of images from the XML that may be of higher and lower resolution than the web dimensions.</p>
  <p>What I want is to use the aspect ration of the web dimensions to display the higher resolution image, if available, on an HD (1280x720) screen, or, if the user is on an SD screen (720x480) display the image on that screen.</p>
  <p>Other things that would be useful for this, but lower priority, would be, if I know the resolution of the image is smaller in both dimensions than an SD screen (in this case, all I know is the web dimension, and the horizontal dimension of the image file), to display it as actual size on that screen.</p>