This is a pretty handy Perl script based on the Image::Size module which can be found at CPAN. It digs through a web site and edits every HTML file, making sure that all the IMG tags have proper HEIGHT and WIDTH tags. If not, it reads the image pointed to by the IMG tag, asks Image::Size to determine the x and y size of the image (height and width), and rewrites the IMG tag properly.
Now you may be asking yourself, "what happens to the images with scaled size?" Well that's the cool part, it leaves them alone. So it doesn't break anything, it just makes the text content and page layout happen faster for the end user.
It's pretty long so I have left it in a standalone document, in plain text format. Just save it and rename it .pl if you like.