i'm trying to get the width of an image but it it always undefine. here is the part of the code
var w;
var _URL = window.URL || window.webkitURL;
var img = new Image();
img.src = _URL.createObjectURL(files[i]);
img.onload = function () {
w = this.width;
console.log(w); // works
};
console.log(w); // undefined
and i notice the the last console log are being called first, and not the console inside a function(), is it the correct behavior? because i thought that it will call a function line by line.
if i input 4 files, the result will be 4 undefined
first, then the actual width of the image.