locked
get height of image using c# RRS feed

  • Question

  • User-1465070452 posted

    Image img = new Image();
                img.ImageUrl =  "admin/images/image.png";

                this.Controls.Add(img);
                Double u  = img.Height.Value;

     

    above code doesnot work. any ideas.

    Friday, October 31, 2008 12:31 PM

Answers

  • User-2064897223 posted

     this worked for me , you can try this way

    System.Drawing.Image objImage = System.Drawing.Image.FromFile("C:\imagename.gif");
    width = objImage.Width;
    height = objImage.Height; 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 31, 2008 1:44 PM

All replies

  • User-2064897223 posted

     this worked for me , you can try this way

    System.Drawing.Image objImage = System.Drawing.Image.FromFile("C:\imagename.gif");
    width = objImage.Width;
    height = objImage.Height; 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 31, 2008 1:44 PM
  • User-1465070452 posted

     i have the path as admin/images/image.png

     

    how can i point to this. instead of looking in the local c drive. i wan to look in the web server folder

    Friday, October 31, 2008 2:00 PM
  • User1356549919 posted

    You can get from this also

     

    System.Drawing.Image objImage = System.Drawing.Image.FromFile("Pass here Byte array of file");
    width = objImage.Width;
    height = objImage.Height; 

    Tuesday, December 2, 2008 1:55 AM