I'm trying to write a simple routine where I pass it a URL and it goes and renders the content of the webresponse as a jpg. I found a solution somehwere in C# and ported it to vb.net, however when I run it, it throws an argumentexception "parameter is not valid" when trying to instantiate the image. Can someone take a look at the following code and let me know if I'm on the right track?
Sub SaveUrl(ByVal aUrl As String)
Dim response As WebResponse
Dim remoteStream As Stream
Dim readStream As StreamReader
Dim request As WebRequest = WebRequest.Create(aUrl)
response = request.GetResponse
remoteStream = response.GetResponseStream
readStream = New StreamReader(remoteStream)
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(remoteStream)
img.Save(aUrl & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
response.Close()
remoteStream.Close()
readStream.Close()
End Sub
To Clarify: Yes, I know i need a LOT more code to accomplish what I want to do, which is to render/take a screen capture of a URL (html, images, all the markup, everything) and save it as a jpg thumbnail.
If you've used Google Chrome, you've seen the launch page that has thumbnails of all the sites you use frequently. Something like that.
Update: Ok I've found commercial paid products to accomplish this, like http://www.websitesscreenshot.com/Index.html but no open source implementations.