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. Advertisements

  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. Advertisements

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. Madhanmohan S
    Replies:
    5
    Views:
    8,141
    Madhanmohan S
    Sep 3, 2004
  2. Andreas Klemt
    Replies:
    6
    Views:
    15,672
    Peter Theill
    Nov 28, 2004
  3. =?Utf-8?B?QmlkYXJrb3Rh?=

    How to set the DataGrid Row Size to a fixed size.

    =?Utf-8?B?QmlkYXJrb3Rh?=, May 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    977
    =?Utf-8?B?QmlkYXJrb3Rh?=
    May 19, 2005
  4. =?Utf-8?B?UGFyYWtp?=

    Image size problem. Image Compression

    =?Utf-8?B?UGFyYWtp?=, Jun 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    605
    Kevin Spencer
    Jun 24, 2005
  5. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,837
    Kartic
    Jan 26, 2005
  6. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    13,425
    Michael Jung
    May 25, 2008
  7. Bob Richardson
    Replies:
    3
    Views:
    358
    Bob Richardson
    Mar 8, 2005
  8. bluedolphin
    Replies:
    1
    Views:
    254
Loading...