Question: Web page images

Posted by: Folsom

Question: Web page images - 10/02/2005 18:50

I have a Dlink internet camera, and I would like to publish a static image from the camera on my website. I would prefer not to open a new port to access the image. Is there an easy way to publish the picture using a server script? I was thinking the server script could grab the image and then send it out.

My server is running IIS, so I tried playing around with asp files. I started with a windows function called URLDownloadToFile. I was thinking of saving the image to the server's hard drive and then displaying the image. The function returns OK, but the file never gets saved. There may be a file system permission problem going on, but I'm not certain.

I also tried using a perl module called LWP::Useragent, but since I don't know perl very well I never got it to work.

Any info would be appreciated, thanks.
Posted by: Dignan

Re: Question: Web page images - 10/02/2005 19:14

Does this do what you want? This just says you need to be able to send HTTP requests on port 80.

*edit*
Which DLink camera do you have? Do you like it? I've been considering getting a webcam for a long while, but haven't found one I like.
Posted by: Folsom

Re: Question: Web page images - 10/02/2005 20:31

Quote:
Does this do what you want?

It looks like that software only works for webcams. I have a DCS-900, and it has a server that supplies images. I can pull the latest image by grabbing "image.jpg" from the camera.

The camera works OK, and it comes with software that will record/monitor the camera. It only costs $30 after rebate, so that is why I got it.
Posted by: g_attrill

Re: Question: Web page images - 10/02/2005 20:33

If you don't want to open an incoming port then you will need software to publish *to* the site, rather than from. You would need some software as listed.

Regarding your ASP problem - make sure you have write permissions for IUSR_machinename, although this normally produces a "permission denied" error. If you have an empty file then you probably have some duff code. To download files on ASP I have found the most reliable method is down using WinHttpRequest and then write with FileSystemObject calls (which I can't remember off-hand, but there are loads of examples on the 'net).

Gareth
Posted by: Folsom

Re: Question: Web page images - 12/02/2005 00:47

Thanks for the pointers. I got the script to work. Is there a way to send the output of WinHttpRequest directly instead of saving the image on the hard drive and then displaying it?
Posted by: andy

Re: Question: Web page images - 12/02/2005 12:24

Quote:
Thanks for the pointers. I got the script to work. Is there a way to send the output of WinHttpRequest directly instead of saving the image on the hard drive and then displaying it?


Probably.

The WinHttpRequest object has a ResponseStream property which returns an IStream object.

If I remember correctly one of the things that the Response.Write method can accept is an IStream object. So calling Response.Write and passing the WinHttpRequest.ResponseStream should write out the image you grabbed.

You will also have to set the Response.ContentType to the relevant mime type for the image format.

Edit:

I was nearly right. You need to do:

dim oBody
oBody = oWinHTTP.responseBody
Response.BinaryWrite oBody

In theory you could just do:

Response.BinaryWrite oWinHTTP.responseBody

but I have had that fail in strange ways in the past