title: How to calculate proportional width of an image based on its height?
body: <p>How to calculate <strong>proportional width</strong> of an image <em>based on its height</em>?</p>
  
  <p>I mean we know only an image height only.</p>
  
  <pre><code>string pathToImage = System.IO.Path.Combine(Settings.ContentFolderPath, file);
  
  Image image = new Image();
  BitmapImage src = new BitmapImage();
  src.BeginInit();
  src.UriSource = new Uri(pathToImage, UriKind.Absolute);
  src.EndInit();
  image.Source = src;
  image.Stretch = Stretch.Uniform;
  image.Height = canvas1.Height;  
  image.Width = ???; 
  </code></pre>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p><strong>UPDATES (1)</strong></p>
  
  <p>Thanks to all folk who have helped me.</p>
  
  <p>And please stupid people don't vote down...</p>
  
  <p><strong>UPDATES (2)</strong></p>
  
  <p>The solution:</p>
  
  <pre><code>string pathToImage = System.IO.Path.Combine(Settings.ContentFolderPath, file);
  
  Image image = new Image();
  BitmapImage src = new BitmapImage();
  src.BeginInit();
  src.UriSource = new Uri(pathToImage, UriKind.Absolute);
  src.EndInit();
  double ratio = src.Width / src.Height; 
  image.Source = src;
  image.Stretch = Stretch.Uniform;
  image.Height = canvas1.Height;  
  image.Width = canvas1.Height * ratio;
  </code></pre>