Image size

J

Jason Carlton

Hello,

How can we calculate size of image by using javascript ?

Thanks in advance


Do you mean dimensions, or file size? I had a similar problem recently
finding the dimensions, and I used:

<img src="whatever.jpg" id="some_image">

var img_width = document.getElementById("some_image").clientWidth;
var img_height = document.getElementById("some_image").clientHeight;


Actually, I used <div id="some_image"><img src="whatever.jpg"></div>,
but I think the logic would apply to just give an ID to the image.

HTH,

Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top