Home All Groups Group Topic Archive Search About

Saving a JPG from the web to local disk

Author
16 May 2006 7:59 PM
Jerry Spence1
I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.

What I would like to go is to build some VB.Net to be able to save this
image to disk. I thought of using a Picturebox as this can show web based
images but saving them to disk becomes rather complicated. Is there any
other way?

-Jerry

Author
16 May 2006 8:44 PM
cSharpLess
"Jerry Spence1" <jerry.spe***@somewhere.com> kirjoitti
viestissä:446a2f19$0$97611$ed261***@ptn-nntp-reader01.plus.net...
>I have an http command such as http://<ip-Address>/getimage to get a jpg
>snapshot image from an IP camera. When I put this into a Web browser it
>shows the image OK.
>
> What I would like to go is to build some VB.Net to be able to save this
> image to disk. I thought of using a Picturebox as this can show web based
> images but saving them to disk becomes rather complicated. Is there any
> other way?

Maybe something like

Dim Client As System.Net.WebClient = New System.Net.WebClient()
Client.DownloadFile("http://www.example.com/image.jpg", "c:/image.jpg")


should do. Didn't test it though.
Author
17 May 2006 6:03 AM
Jerry Spence1
Show quote Hide quote
"cSharpLess" <no@mails.invalid> wrote in message
news:uevFHmSeGHA.3888@TK2MSFTNGP04.phx.gbl...
>
> "Jerry Spence1" <jerry.spe***@somewhere.com> kirjoitti
> viestissä:446a2f19$0$97611$ed261***@ptn-nntp-reader01.plus.net...
>>I have an http command such as http://<ip-Address>/getimage to get a jpg
>>snapshot image from an IP camera. When I put this into a Web browser it
>>shows the image OK.
>>
>> What I would like to go is to build some VB.Net to be able to save this
>> image to disk. I thought of using a Picturebox as this can show web based
>> images but saving them to disk becomes rather complicated. Is there any
>> other way?
>
> Maybe something like
>
> Dim Client As System.Net.WebClient = New System.Net.WebClient()
> Client.DownloadFile("http://www.example.com/image.jpg", "c:/image.jpg")
>
>
> should do. Didn't test it though.
>
Thanks for this. Worked a treat. Very useful!

-Jerry
Author
17 May 2006 12:41 PM
Jerry Spence1
>> Maybe something like
>>
>> Dim Client As System.Net.WebClient = New System.Net.WebClient()
>> Client.DownloadFile("http://www.example.com/image.jpg", "c:/image.jpg")
>>
>>
>> should do. Didn't test it though.
>>
> Thanks for this. Worked a treat. Very useful!
>
> -Jerry
>
>
Actually I'm not quite out of problems. I'm getting an error:

"The server committed an HTTP protocol violation"

My exe file is Housekeeper 5.0.exe and I understand I need to produce a file
called Housekeeper 5.0.exe.config containing the following:

<?xml version="1.0" encoding="utf-8"
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>

I have placed this in the project folder (is that right?) but I still get
the error message. Do I need to load it or anything, or just leave it in the
folder? Have I done everything right?

-Jerry
Author
16 May 2006 8:53 PM
Herfried K. Wagner [MVP]
"Jerry Spence1" <jerry.spe***@somewhere.com> schrieb:
>I have an http command such as http://<ip-Address>/getimage to get a jpg
> snapshot image from an IP camera. When I put this into a Web browser it
> shows the image OK.

'WebClient.DownloadFile'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 May 2006 11:26 PM
gene kelley
On Tue, 16 May 2006 20:59:20 +0100, "Jerry Spence1"
<jerry.spe***@somewhere.com> wrote:

>I have an http command such as http://<ip-Address>/getimage to get a jpg
>snapshot image from an IP camera. When I put this into a Web browser it
>shows the image OK.
>
>What I would like to go is to build some VB.Net to be able to save this
>image to disk. I thought of using a Picturebox as this can show web based
>images but saving them to disk becomes rather complicated. Is there any
>other way?
>
>-Jerry
>
Yet, another option:

My.Computer.Network.DownloadFile("http://SomeDomain/Some.jpg",  _
"c:/SomeFolder/Some.jpg")

There are 9 other overrides to this to this to handle such things as
credentials, overwrite etc.

Gene
Author
17 May 2006 5:03 AM
Jerry Spence1
Show quote Hide quote
"gene kelley" <o***@by.me> wrote in message
news:qnnk62l0o8gbcv1cuoivtlajkvqa4s6hf8@4ax.com...
> On Tue, 16 May 2006 20:59:20 +0100, "Jerry Spence1"
> <jerry.spe***@somewhere.com> wrote:
>
>>I have an http command such as http://<ip-Address>/getimage to get a jpg
>>snapshot image from an IP camera. When I put this into a Web browser it
>>shows the image OK.
>>
>>What I would like to go is to build some VB.Net to be able to save this
>>image to disk. I thought of using a Picturebox as this can show web based
>>images but saving them to disk becomes rather complicated. Is there any
>>other way?
>>
>>-Jerry
>>
> Yet, another option:
>
> My.Computer.Network.DownloadFile("http://SomeDomain/Some.jpg",  _
> "c:/SomeFolder/Some.jpg")
>
> There are 9 other overrides to this to this to handle such things as
> credentials, overwrite etc.
>
> Gene

I tried this but 'My' wasn't defined. Where does it come from?

-Jerry
Author
17 May 2006 6:32 AM
gene kelley
On Wed, 17 May 2006 06:03:53 +0100, "Jerry Spence1"
<jerry.spe***@somewhere.com> wrote:

Show quoteHide quote
>
>"gene kelley" <o***@by.me> wrote in message
>news:qnnk62l0o8gbcv1cuoivtlajkvqa4s6hf8@4ax.com...
>> On Tue, 16 May 2006 20:59:20 +0100, "Jerry Spence1"
>> <jerry.spe***@somewhere.com> wrote:
>>
>>>I have an http command such as http://<ip-Address>/getimage to get a jpg
>>>snapshot image from an IP camera. When I put this into a Web browser it
>>>shows the image OK.
>>>
>>>What I would like to go is to build some VB.Net to be able to save this
>>>image to disk. I thought of using a Picturebox as this can show web based
>>>images but saving them to disk becomes rather complicated. Is there any
>>>other way?
>>>
>>>-Jerry
>>>
>> Yet, another option:
>>
>> My.Computer.Network.DownloadFile("http://SomeDomain/Some.jpg",  _
>> "c:/SomeFolder/Some.jpg")
>>
>> There are 9 other overrides to this to this to handle such things as
>> credentials, overwrite etc.
>>
>> Gene
>
>I tried this but 'My' wasn't defined. Where does it come from?
>
>-Jerry
>

My Namespace >> introduced in VS2005.  You must be using an earlier
version. 
I'm not familiar with the older versions as to what to use in that
case.

Gene
Author
17 May 2006 8:21 AM
Cor Ligthert [MVP]
> My Namespace >> introduced in VS2005.  You must be using an earlier
> version.
> I'm not familiar with the older versions as to what to use in that
> case.
>
Have a look at the message from Herfried,

Cor
Author
17 May 2006 8:45 AM
Jerry Spence1
>
> My Namespace >> introduced in VS2005.  You must be using an earlier
> version.
> I'm not familiar with the older versions as to what to use in that
> case.
>
> Gene

Yes I am. Thanks. Good incentive to upgrade!

-Jerry