PDA

View Full Version : image size


pratamishus
07-31-2009, 10:25 AM
Hi!

Can anyone tell me how to get a loaded image size through javascript. I've been told that it's probably possible to get it with DOM objects, but do not really know how to do that.

If not possible directly, is it possible to get the headers of a loaded file, so that I could separate the file size from "content-length" header part.

Thanks in advance,
Tim.

glenngv
07-31-2009, 10:10 PM
<img src="image.jpg" onload="getSize(this);" alt="" />

function getSize(img){
alert(img.width + " x " + img.height);
}