title: How to retrieve width and height properties of an image from SQL Server?
body: <p>I am retrieving an image from SQL Server to display on a new page in my ASP.NET 4.0 application using this method (one of my posts):</p>
  
  <p><a href="https://stackoverflow.com/questions/4097438/how-to-display-an-image-based-on-selectedvalue-in-a-gridview">How to display an image based on SelectedValue in a GridView?</a></p>
  
  <p>I am then displaying the image in a new window using this method: (one of my posts):</p>
  
  <p><a href="https://stackoverflow.com/questions/4104785/how-to-display-an-image-in-a-new-window">How to display an image in a new window</a></p>
  
  <p>What I am trying to do is get the height and width of the image so that the new window is created with the same height and width as the stored image. I guess there are two ways of doing this:</p>
  
  <ol>
  <li>Create a height and width column in my database and store the values when the image is inserted into the database</li>
  <li>Retrieve the image from the database and calculate somehow the height and width just before displaying it and then resize the browser window to the right size.</li>
  </ol>
  
  <p>I already have over 150 images in the database so that makes option 1 difficult because I would have to go back over my db and calculate height and width for images that are already in the db. Therefore I would prefer to use option 2, or maybe there's another option? How would I go about doing this?</p>
  
  <p>Thanks for looking.</p>