Figuring out different properties of a Image from its URL

Sometimes while working with image, it become necessary to get all the properties of an image. This time, I had to find out all the properties of an Image deployed in a web site.Its interesting- that’s why I wanted to share the small code snippet. For our today’s example – let’s pick this gif from our favorite –

We will find out all the properties from the Image URL.

Something About Bitmap Class of System.Drawing –

It represents the pixel data of the graphics image as GDI+ Bitmap and expose all the attributes related to the Image Graphics. In addition to that, it enables manipulation of the Bitmap and save it as File in different format.

There are many overloaded Constructor in the Bitmap class  which enables to create image object in various way at developers convenience.

Using WebRequest and WebResponse class of we can retrieve the Stream of the Image.

string url = "";  

WebRequest request = WebRequest.Create(url); 
request.Method = "Get";  

WebResponse response = request.GetResponse(); 
Stream stream = response.GetResponseStream();

And then we can just initialize a Bitmap object with the stream that we have just retrieved from the URL.

Bitmap bitmap = new Bitmap(stream);

We are done. :) We can access all the properties exposed by the Bitmap object representing the Image Graphics –



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: