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

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

  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. 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. Mustafa Rabie

    Getting image height n width?

    Mustafa Rabie, Jan 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,105
    Ryan Trudelle-Schwarz
    Jan 21, 2005
  2. King W.Wang
    Replies:
    4
    Views:
    1,003
  3. Lois
    Replies:
    1
    Views:
    3,312
    Ryan Stewart
    Dec 27, 2004
  4. cera
    Replies:
    1
    Views:
    1,301
    Neredbojias
    Aug 18, 2007
  5. Bernd Meier
    Replies:
    6
    Views:
    529
    GTalbot
    Jan 14, 2008
Loading...

Share This Page