Getting the width/height of an image

Discussion in 'ASP .Net' started by Nathan Sokalski, May 24, 2005.

  1. I need to get the width and height of a GIF image through code. I need this
    info so that I can set the width and height properties of Image and
    ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem
    to return properties that all files have, which does not include width and
    height. How can I get this info? Any help would be appreciated. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, May 24, 2005
    #1
    1. Advertisements

  2. "Nathan Sokalski" <> schrieb:
    >I need to get the width and height of a GIF image through code. I need this
    >info so that I can set the width and height properties of Image and
    >ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem
    >to return properties that all files have, which does not include width and
    >height. How can I get this info?


    Load the file using 'Image.LoadFrom' and check the 'Image' object's 'Height'
    and 'Width' properties.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>
     
    Herfried K. Wagner [MVP], May 24, 2005
    #2
    1. Advertisements

  3. I seem to be having trouble doing this. Do you have a small example? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Herfried K. Wagner [MVP]" <> wrote in message
    news:%...
    > "Nathan Sokalski" <> schrieb:
    >>I need to get the width and height of a GIF image through code. I need
    >>this info so that I can set the width and height properties of Image and
    >>ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem
    >>to return properties that all files have, which does not include width and
    >>height. How can I get this info?

    >
    > Load the file using 'Image.LoadFrom' and check the 'Image' object's
    > 'Height' and 'Width' properties.
    >
    > --
    > M S Herfried K. Wagner
    > M V P <URL:http://dotnet.mvps.org/>
    > V B <URL:http://classicvb.org/petition/>
     
    Nathan Sokalski, May 25, 2005
    #3
  4. "Nathan Sokalski" <> schrieb:
    >I seem to be having trouble doing this. Do you have a small example?
    >Thanks.


    \\\
    Dim i As Image = Image.FromFile("C:\WINDOWS\Angler.bmp")
    MsgBox(i.Width.ToString() & " " & i.Height.ToString())
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>
     
    Herfried K. Wagner [MVP], May 25, 2005
    #4
    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. Mustafa Rabie

    Getting image height n width?

    Mustafa Rabie, Jan 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,289
    Ryan Trudelle-Schwarz
    Jan 21, 2005
  2. AndrewF
    Replies:
    1
    Views:
    1,039
    Bruce Barker
    Oct 10, 2005
  3. King W.Wang
    Replies:
    4
    Views:
    1,144
  4. Sean Jorden
    Replies:
    1
    Views:
    750
    laurie
    Aug 19, 2003
  5. Lois
    Replies:
    1
    Views:
    4,152
    Ryan Stewart
    Dec 27, 2004
  6. cera
    Replies:
    1
    Views:
    1,652
    Neredbojias
    Aug 18, 2007
  7. Bernd Meier
    Replies:
    6
    Views:
    711
    GTalbot
    Jan 14, 2008
  8. samer
    Replies:
    3
    Views:
    614
    Gregory A. Beamer
    Sep 28, 2009
Loading...