Get image dimensions with Javascript before image has fully loaded
<div id="info"></div>
<img id="image" src="http://domain.com/images/example-source.jpg">
<script>
getImageSize('#image', function(width, height) {
$('#info').text(width + ',' + height);
});
function getImageSize(img, callback) {
var $img = $(img);
var wait = setInterval(function() {
var w = $img[0].naturalWidth,
h = $img[0].naturalHeight;
if (w && h) {
clearInterval(wait);
callback.apply(this, [w, h]);
}
}, 30);
}
</script>