title: Getting an image dimensions
body: <p>I've got a problem with getting image dimensions. I want to know the width and height of image without its loading into document. At present I have code as follows:</p>
  
  <pre><code> function getImageSize (path) {
    var image = new Image();
    image.name = path;
    var d = image.onload = function() {
     var w = this.width;
     var h = this.height;
     return {width : w, height : h};
    }();
    image.src = path;
    return d;
   }
  </code></pre>
  
  <p>If I call that function, I get object containing undefined in both index (w, h). I've tried not call onload handler by exclude parenthesis (8 line) but what I get is function code.</p>
  
  <p>Note that if I call <code>alert(w)</code> inside onload handler body, I can see width of picture but outside it not.</p>
  
  <p>Does someone know how to solve that problem? How can I get image dimension?</p>