The Problem
I wanted to grab the width and height of an image that was on a remote server. I've done this with PHP, but never in .NET.
The Solution
I did a little digging and came across this code (slightly modified for my own purposes).
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(URL), HttpWebRequest)
request.Method = "GET"
request.Accept = "image/*"
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Dim s As Stream = response.GetResponseStream()
Dim bmp As New Bitmap(s)
Width = bmp.Width
Height = bmp.Height
Comments
Post a Comment