Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Image size

Thread Tools

Image size

Posts: n/a

How can we calculate size of image by using javascript ?

Thanks in advance
Reply With Quote
Jason Carlton
Posts: n/a
On Nov 26, 12:40*am, ozone <(E-Mail Removed)> wrote:
> 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.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Image size problem. Image Compression =?Utf-8?B?UGFyYWtp?= ASP .Net 1 06-24-2005 11:55 AM
How to Shrink image size when browser size is reduced Bob Richardson Javascript 3 03-08-2005 06:37 AM
Bigger image size and lower quality vs. Smaller image size and higher quality Desmond Digital Photography 5 09-27-2003 04:08 AM