Take the 2-minute tour ×

Possible Duplicate:
Get the resolution of a jpeg image using C# and the .NET Environment?

In a batch image downloader I am coding, I use a WebClient (DownloadFile) to save images from given urls. Is there an easy way to get the resolution of these images? If the WebClient cannot, how can i get the resolution after the file is saved?

share|improve this question

marked as duplicate by casperOne Jun 29 '12 at 17:36


2 Answers 2

up vote 1 down vote accepted

If you save the image after downloading it from the WebClient, you can use the following:

Image img = Image.FromFile(@"image.png");
Console.WriteLine(img.Width + "x" + img.Height);

This will give you the width x height of the image, for example, 1920x1080.

share|improve this answer

To get the DPI use the following:

Image image = Image.FromFile("image.jpg");

For other things such as height, width, and size, view this stackoverflow question which has many good answers, (including mine :D ).

share|improve this answer
