var newImg = new Image(); newImg.onload = function() { $iw = newImg.width; $ig = newImg.height; } newImg.src = src;