title: Get height/width of image in Javascript (ideally without loading the image at all)
body: <p>Sorry if this has already been answered, but I can't find it if so.</p>
  
  <p>I want to find the height and width of an image file in Javascript. I don't actually need to show the image in the page, just the height and width.</p>
  
  <p>At the moment I've got the following code, but it's returning height and width 0 (in Mozilla 5).</p>
  
  <pre><code>  var img = new Image();
    img.src = "./filename.jpg";
    var imgHeight = img.height;
    var imgWidth = img.width;
    alert("image height = "  + imgHeight + ", image width = " + imgWidth);
  </code></pre>
  
  <p>The file definitely exists, it's in the same directory as the HTML, and it doesn't have height and width 0 :)</p>
  
  <p>What am I doing wrong?</p>