title: Constrain image size to max height and max width according to aspect ratio
body: <p>I've a function called <code>getMediaSize</code> that accepts a image height and image width:</p>
  
  <pre class="lang-js prettyprint-override"><code>const MAX_HEIGHT = 500
  const MAX_WIDTH = 600
  function getMediaSize(iw, ih) {
  
  }
  </code></pre>
  
  <p>I'd like the function to return the new image width and height that fits the <code>MAX_WIDTH x MAX_HEIGHT</code> dimensions according to the aspect ratio.</p>
  
  <p>For example, <code>getMediaSize(1200, 800)</code> should return <code>{ w: 600, h: 400 }</code></p>