C # obtain the width and height codes of online images

Source: Internet
Author: User

Use Visual Studio to create a Console application. Remember to reference the assembly System. Drawing;

The Code is as follows:

Using System;
Using System. Drawing;
Using System. IO;
Using System. Net;

Namespace Keleyi. Com
{
Class KeleyiImage
{
Static void Main (string [] args)
{
WebRequest request = WebRequest. Create (@ "http://keleyi.com/image/a/tvh00n12.jpg ");
Request. Credentials = CredentialCache. DefaultCredentials;
Stream s = request. GetResponse (). GetResponseStream ();

Byte [] B = new byte [74373];
MemoryStream mes_keleyi_com = new MemoryStream (B );
S. Read (B, 0, 74373 );
S. Close ();
Image image = Image. FromStream (mes_keleyi_com );
Console. WriteLine ("high {0}, Width {1}", image. Height, image. Width );
Console. WriteLine ("For more information, visit keleyi.com and press any key to exit-ke leyi ");
Console. ReadKey ();
}
}
}

 

Original article: http://keleyi.com/a/bjac/f37p93cv.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.