Image size

Discussion in 'Javascript' started by ozone, Nov 26, 2009.

  1. ozone

    ozone Guest

    Hello,

    How can we calculate size of image by using javascript ?

    Thanks in advance
     
    ozone, Nov 26, 2009
    #1
    1. Advertising

  2. On Nov 26, 12:40 am, ozone <> 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.

    HTH,

    Jason
     
    Jason Carlton, Nov 26, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGFyYWtp?=

    Image size problem. Image Compression

    =?Utf-8?B?UGFyYWtp?=, Jun 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    499
    Kevin Spencer
    Jun 24, 2005
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,395
    Kartic
    Jan 26, 2005
  3. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,654
    Michael Jung
    May 25, 2008
  4. Bob Richardson
    Replies:
    3
    Views:
    247
    Bob Richardson
    Mar 8, 2005
  5. bluedolphin
    Replies:
    1
    Views:
    166
Loading...

Share This Page