...

View Full Version : Save snapshot web camera



jammyjames
11-20-2006, 08:46 AM
Hi,

I have a web site called www.yarmouthportal.com and I currently pay a lot of money for someone to proide me with a couple of benifits such as Saving a Snapshot and Emailing a Snapshot.


Now I am able to get a temporary (updates when the browser refreshes) snapshot from the camera but I don't know how to upload the image to my server. Currently I would have to right click then save as. I want this to be a bit more user friendly such as the one currently www.yarmouthportal.com/camera/index.php

Can anyone please help me?

Thanks

mlseim
11-20-2006, 02:06 PM
Could you show us how you get the photo?
Perhaps you're using a PHP script already, or Javascripting?

jammyjames
11-20-2006, 06:56 PM
Hi,

Ok this is the image location http://217.155.209.14:2220/SnapshotJPEG?Resolution=320x240&Quality=Standard

This is updated every time you refresh.

I want to be able to include that in my Yarmouth Portal site and then when I click "Save Snapshot" it will prompt me to save this image to my computer.

Thanks for any help

mlseim
11-20-2006, 07:47 PM
I'm just confused here ...

On this page:
http://www.yarmouthportal.com/camera/index.php

You already are displaying the webcam shot and there are
links to email or save. How is this different from your question?

... and this link times-out:
http://217.155.209.14:2220/SnapshotJPEG?Resolution=320x240&Quality=Standard

jammyjames
11-20-2006, 08:43 PM
Sorry,

On the Yarmouth Portal site features an existing program which I pay a lot of money every month for. I can't afford to pay it and I know that there is a way to do it myself. Somehow.

mlseim
11-20-2006, 09:54 PM
So do you have a link where you can get your camera image?

.... a way to view the photo for free? (or is that part of the package)?

Somewhere along the line, that webcam is hooked up to a PC or something
that puts the image on the internet. Is that part of your system, or are you
paying for that?

jammyjames
11-20-2006, 10:46 PM
This is the snapshot direct from the camera http://217.155.209.14:2220/SnapshotJPEG?Resolution=320x240&Quality=Standard

As i said everytime the page is refreshed the image will change unless it has been saved.

mlseim
11-21-2006, 02:50 AM
OK,

I'm going to look for a PHP solution to this.
A way to grab the image and create some options
to save or email.

Until then, someone may jump in with another solution.

firepages
11-21-2006, 02:58 AM
ok , first off who `owns` the webcamera ? and the bandwidth it uses... they need to give you permission to use images from it, if thats the case then the solution is easy, but if you don't have rights to use the image then we can't help you `grab` it here.

Please advise.

actually, it appears possible for anyone to control that camera ... not good!

jammyjames
11-21-2006, 08:59 AM
Thanks I would really appreciate the help.

The site, IP address and Web Camera are all mine and I have full rights to them.

The camera can be controlled by anyone by using up to 8 presets. This is as far as a guest user can go.

Regards

firepages
11-21-2006, 09:36 AM
OK...


<?php
/*where to get*/
$url="http://217.155.209.14:2220/SnapshotJPEG?Resolution=320x240&Quality=Standard";
/*where to put*/
$img_path='/home/fire/Desktop/snap'.mktime.'.jpg';

$yaks=file_get_contents($url);
$fp=fopen($img_path,'wb');
fputs($fp,$yaks);
fclose($fp);
?>


I put a timestamp at the end of the filename but whatever...

firepages
11-21-2006, 09:42 AM
ah ok missed the bit about saving the image..

you could run the above code when someone clicks the 'save image' button then ... pass the img_path to something like this


<?php
function force_download($path){
$file=basename($path);
header("Content-Type: application/octet-stream");
header("Content-Type: application/force-download");
header("Content-Length: $size");
// Required to get around the MSIE 5.5 Bug of downloading filname.php
if(preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT']))
{

header("Content-Disposition: filename=\"$file\"");
} else
{
header("Content-Disposition: attachment;filename=$file");
}
//header("Content-Transfer-Encoding: binary");
$fh = fopen($path, "rb");
fpassthru($fh);
}
?>

jammyjames
11-21-2006, 11:08 AM
Hi

ok code looks great.

Excuse me if I am being stupid but how would I pass the image onto the next script you posted?

I really appreciate your help! :thumbsup: :) :thumbsup:

Regards

mlseim
11-21-2006, 03:45 PM
James ...

I was also looking into using PHP GD library for doing something like
putting a watermark or text directly on the image ... maybe to indicate
camera location, time, etc. Would you be interested in anything like that?

Firepages provided the good stuff for saving image, much better than the
solution I had, so go with that.

jammyjames
11-21-2006, 07:47 PM
Hi all I am always looking for ways to improve what I have.

Firepages, I really appreciate the help but i'm not sure how to implement this script. :o I tried just running the first script alone but it just spat loads of errors at me beginning from line 7.

If you could help me I would really appreciate it.

Regards,

James

firepages
11-22-2006, 03:09 AM
ok you probably need to edit the permissions of where you are trying to save the image, the directory needs to be writable .. I assume those are the errors you are getting..

here's an example .. its not exactly how I would do it but you get the general idea from it.. http://www.phptoday.net/tmp.php

the tmp directory needs to be writable, on many hosts that means chmod to 0777 (if you have root you can chown the folder instead)

mlseim
11-22-2006, 03:10 AM
James ...

The first example works.
I'm guessing that you don't have the CHMOD
permission set right in the folder where you
are writing the file, so you get a permission error.

In his example, he used this path:
$img_path='/home/fire/Desktop/snap'.mktime.'.jpg';

You will use your own path, perhaps something like this:
$img_path='./photos/snap'.mktime.'.jpg';

.... where the directory "photos" will have a CHMOD of 777.

We of course, can determine what your directory structure is,
so you'll have to determine that yourself.

===============

There is an interesting paradox though ...

When you go to your webpage and the webcam photo appears,
you may sit and look at it for a while, then decide to "save it".
So you click "save". Well, during that time that you sat and stared
at your screen, the webcam has already taken a new photo, so the
one you are looking at on your screen is older than the one that is
saved when you hit the button. See what I mean?
You'll have to determine how often the photo is updated and somehow
refresh your screen so you're seeing the newest image.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum