user682417 user682417 - 2 months ago 21
C# Question

How to get the image dimension from the file name

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, and if either width or height of the image is less than or equal to zero, pop up a message like "image not in correct format"

Can anyone help me please?

System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\ggs\ggs Access\images\members\1.jpg");
MessageBox.Show("Width: " + img.Width + ", Height: " + img.Height);