Getting image height n width?

Discussion in 'ASP .Net' started by Mustafa Rabie, Jan 21, 2005.

  1. dear all,

    i am writing an application where the user can upload his own picture. I
    wanted to get the Width and Height of the uploaded picture. So i assigned
    the uploaded image to an aspnet image control, but when i call the height
    and width properties of the image control it returns "" since they are not
    set. So how can i get this info?

    thanks
    mustafa
    Mustafa Rabie, Jan 21, 2005
    #1
    1. Advertising

  2. > dear all,
    >
    > i am writing an application where the user can upload his own picture.
    > I wanted to get the Width and Height of the uploaded picture. So i
    > assigned the uploaded image to an aspnet image control, but when i
    > call the height and width properties of the image control it returns
    > "" since they are not set. So how can i get this info?
    >
    > thanks
    > mustafa


    Easiest way is to load it into an Image object (System.Drawing.Image) and
    query it from there.

    So something along the lines of:

    Image image = Image.FromStream(file.InputSteam);

    Int32 height = image.Height;
    Int32 width = image.Width;

    image.Dispose();
    (that may close the input stream, I'm not sure)
    Ryan Trudelle-Schwarz, Jan 21, 2005
    #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. Nathan Sokalski

    Getting the width/height of an image

    Nathan Sokalski, May 24, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    537
    Herfried K. Wagner [MVP]
    May 25, 2005
  2. King W.Wang
    Replies:
    4
    Views:
    980
  3. Lois
    Replies:
    1
    Views:
    3,171
    Ryan Stewart
    Dec 27, 2004
  4. cera
    Replies:
    1
    Views:
    1,237
    Neredbojias
    Aug 18, 2007
  5. Bernd Meier
    Replies:
    6
    Views:
    495
    GTalbot
    Jan 14, 2008
Loading...

Share This Page