Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to check the image height and width if we upload an image using fileuploader..i want to allow the image to save, if it having dimensions like 677x100,496x255 and 126px × 129px... how can i check the height and width ....i want to give this dimensions according to the conditions....
Posted
Comments
sahabiswarup 17-Nov-12 1:34am    
why don't you using that fileuploader property? you'll get all the required information from there.
Member 9492907 17-Nov-12 2:04am    
i got the answer...thankyou

1 solution

Call this function just before saving the image

C#
public bool ValidateFileDimensions()
 {
   using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream))
   {
     return (myImage.Height == height && myImage.Width == width);
   }
 }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900