ali raza

C#, .Net , and my thoughts

How to get uploaded image dimensions in

I used following code to get uploaded image dimensions .
Where flLogoUplaoded is name of asp .net file uploaded control at my application
string UploadedImageType = flLogoUpload.PostedFile.ContentType.ToString().ToLower();
string UploadedImageFileName = flLogoUpload.PostedFile.FileName;

//Create an image object from the uploaded file
System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(flLogoUpload.PostedFile.InputStream);

//Determine width and height of uploaded image
float UploadedImageWidth = UploadedImage.PhysicalDimension.Width;
float UploadedImageHeight = UploadedImage.PhysicalDimension.Height;

Response.Write( UploadedImageWidth + “<br />”);
Response.Write(UploadedImageHeight + “<br />”);

4 responses to “How to get uploaded image dimensions in

  1. Marta Paniti April 29, 2008 at 7:36 pm

    Thanks! It was very helpful for me!

  2. Ed January 5, 2009 at 10:06 pm

    Awesome — thanks a lot.

  3. Ahmed April 20, 2009 at 12:10 pm

    Thank you so much!!

  4. oo August 6, 2009 at 8:31 am

    Be aware that this loads the entire image into memory. If you have a large number of simultaneous uploads or people upload big images, your server memory will suffer.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: