The image may not have loaded yet. So, try (untested):
function imageSize(img){
var theImage = new Image();
$(theImage).load(function() {
var imgwidth = this.width;
var imgheight = this.height;
alert(imgwidth+'-'+imgheight);
});
theImage.src = img.attr('src');
}