How to get the width and height of a image by its given URL?

G

Guest

I want to get the pixel size of a image file, which is specified by its URL. The problem is how to load the image file by a URL, and then how to get its size? I'm looking for any useful advices.
 
S

Scott Allen

..NET makes this pretty easy using classes from the System.Drawing and
System.NET namespaces:

string imageUrl =
"http://msdn.microsoft.com/nodehomes/graphics/80x60/aspnet.jpg";

WebRequest request = WebRequest.Create(imageUrl);
WebResponse response = request.GetResponse();
Image image = Image.FromStream(response.GetResponseStream());

Console.WriteLine("Image size: {0}x{1}",
image.Width, image.Height);

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top