How to get the the dimensions of an image file?

user682417 picture user682417 · Jun 23, 2011 · Viewed 93.1k times · Source

I have a file called FPN = "c:\ggs\ggs Access\images\members\1.jpg "

I'm trying to get the dimension of image 1.jpg, and I'd like to check whether image dimension is valid or not before loading.

Answer

John T picture John T · Jun 23, 2011
System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\ggs\ggs Access\images\members\1.jpg");
MessageBox.Show("Width: " + img.Width + ", Height: " + img.Height);