in reply to determining size of image

I'm NOT trying to resize the image itself, just the HTML code of the image.

I suggest not doing that. Browsers suck at scaling images, and transfering all those bytes across a network just to have detail thrown away is a waste of bandwidth.