How to know the width & height of an uploaded image in ASP.NET

ఇమేజ్ యొక్క పొడవు వెడల్పు in ASP.NET

Import the namespace using System.IO;
Step 1:
using System.IO;

Step 2:
System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(Image1.PostedFile.InputStream);
Here Image1 is the name of uploaded image.

System.Drawing.Image.FromStream
Creates an Image from the specified data stream.
To know more visit: http://msdn.microsoft.com/en-us/library/system.drawing.image.fromstream.aspx

Step 3:
Now you can get width and height of image using

UploadedImage.Width
UploadedImage.Height

Advertisements