Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Size image from link

Tags:

c#

I want to check size image from url in C#.

Ex: Url: http://img.khoahoc.tv/photos/image/2015/05/14/hang_13.jpg

like image 323
Nam Le Avatar asked Jan 03 '17 03:01

Nam Le


People also ask

How do I find the image size for a URL?

Hover over the URL to see the pop up with all of the image properties. This pop up includes the Rendered size – the dimensions that the website needs – as well as the Intrinsic size – the dimensions of the originally image uploaded.

How do you find the width and height of an image in HTML?

You can easily find the original or intrinsic width and heigh of an image using the HTML5 image naturalWidth and naturalHeight properties. These properties are supported in all major web browsers such as Chrome, Firefox, Safari, Opera, Internet Explorer 9 and above.


1 Answers

Download and check:

string image = @"http://img.khoahoc.tv/photos/image/2015/05/14/hang_13.jpg";
byte[] imageData = new WebClient().DownloadData(image);
MemoryStream imgStream = new MemoryStream(imageData);
Image img = Image.FromStream(imgStream);

int wSize = img.Width;
int hSize = img.Height;
like image 80
Backs Avatar answered Sep 18 '22 15:09

Backs