Use $(this)
in your loop to manipulate the right DOM Element (your image tag)
And use naturalWidth
and naturalHeight
to get the correct size of the image.
$(".real img").each(function(){
var widthImage = $(this).naturalWidth;
var heightImage = $(this).naturalHeight;
if(widthImage > heightImage ){
$(this).addClass('realHeight');
}else{
$(this).addClass('realWidth');
}
});