1
我想從C#中的URL檢查大小圖像。 例如:網址:http://img.khoahoc.tv/photos/image/2015/05/14/hang_13.jpg從鏈接中獲取大小圖像
請幫幫我。非常感謝你
我想從C#中的URL檢查大小圖像。 例如:網址:http://img.khoahoc.tv/photos/image/2015/05/14/hang_13.jpg從鏈接中獲取大小圖像
請幫幫我。非常感謝你
下載並檢查:
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;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(@"http://img.khoahoc.tv/photos/image/2015/05/14/hang_13.jpg";);
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream stream = response.GetResponseStream();
Image img = Image.FromStream(stream);
stream.Close();
MessageBox.Show("Height: " + img.Height + " Width: " + img.Width);
參考http://stackoverflow.com/questions/12079794/get-size-of-image-file-before-downloading-from織網 – GSP