title: HTML5 - how to get image dimension
body: <p>I have this script, it's used to fetch the width and the height of browser uploaded image. </p>
  
  <p>reference: <a href="http://renevier.net/misc/resizeimg.html" rel="nofollow noreferrer">http://renevier.net/misc/resizeimg.html</a></p>
  
  <pre><code>function createReader(file) {
      reader.onload = function(evt) {
          var image = new Image();
          image.onload = function(evt) {
              var width = this.width;
              var height = this.height;
              alert (width); // will produce something like 198
          };
          image.src = evt.target.result; 
      };
      reader.readAsDataURL(file);
  }
  
  for (var i = 0, length = input.files.length; i &lt; length; i++) {
      createReader(input.files[i]);
  }
  </code></pre>
  
  <p>I want to access the value width and height from outside the <code>createReader</code> function. How can I do that?</p>