Image img = System.Drawing.Image.FromFile("test.jpg");
int width = img.Width;
int height = img.Height;
You may need to add the System.Drawing reference.
You may also use the FromStream
function if you have not saved the image to disk yet, but looking at how you're using the image (viewable by user in an Image control), I suspect it's already on disk. Stream to image may or may not be faster than disk to image. You might want to do some profiling to see which has better performance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…