title: Scaling image by using width and height properties to fit in specified rectangle
body: <p>Let's say I have a rectangle area (defined for example by a <code>div</code>) with some specified width and height. And I have an image with unpredictable size and aspect ratio.</p>
  
  <p>If I'd like that image to fit withing given rectangle area and keep the original aspect ratio, how do I do it?</p>
  
  <p>If I know in advance which side will be limiting I could specify only one dimension. For example if the rectangle have size 200x100 px and the image have size 400x300 px I could use <code>&lt;img src="link/to/my/image.jpg" height="100px"&gt;</code> code and the image will keep its aspect ratio and will feet into my rectangle. But if the rectangle will be for example 100x100px the image will go out of the rectangle by the sides.</p>
  
  <p>So the only thing I could do is to hind out the image size and do some simple calculations to define both width and height of the image to: keep the original ration and to fit in the specified rectangle for all possible combinations.</p>
  
  <p>But it looks a bit complicated and requires to use graphic library on server side. May be I miss some HTML capabilities?</p>