el problema es que lo que tu quieres hacer está fuera del each.
    
Código javascript
:
Ver original$(document).ready(function(){
    imgs = document.getElementsByTagName("img");
    $.each(imgs,function(i,n){
        w = n.width; // w queda con el último valor.
    });
    $("img").css({width:80,height:80});
    $("img").click(function(){
        alert(w);
    });
});
 
$('img').click(function(){
   var h = $(this).attr('width');
   var w = $(this).attr('height');
   $(this).animate({width:w,height:h},"slow");
});
  
espero te ayude con tu problema...