Originally Posted by
Rob van der Does
I tried this for my IP-cam, and although this works fine when used in a browser (so address and user/pass are fine), I get no picture at
all in L4L. Any idea?
The best way to check the url of your IP camera snaphot is to click on the snapshot icon in your IP webif and then check its url.
Did you try that URL in your browser first?
Update: I have four IP cameras, two are the same make and the other two are two different makes. All of them have the very same URL structure.
Update 2: Now I see there's more posts here :P
Update 3: I use this bit of code n cron:
HTML Code:
<?
$oldfilename = 'snapshot.cgi?user=user&pwd=password';
$newfilename = date('Ymd_Hi', time() - 3600).".jpg";
$newfilename2 = date('Ymd_Hi', time() - 3600).".jpg";
define('BUFSIZ', 4095);
$url = 'http://55.66.77.88:99999/snapshot.cgi?user=user&pwd=password';
$rfile = fopen($url, 'r');
$lfile = fopen(basename($url), 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);
rename($oldfilename,$newfilename);
$SourceFile = $newfilename;
$DestinationFile = $newfilename;
$WaterMark = date('d.m.Y H:i', time() - 3600)." ";
watermarkImage ($SourceFile, $WaterMark, $DestinationFile);
function watermarkImage ($SourceFile, $WaterMark, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$color = imagecolorallocate($image_p, 255, 0, 255);
$font = 'visitor2.ttf';
$font_size = 11;
imagettftext($image_p, $font_size, 0, 10, 470, $color, $font, $WaterMark);
if ($DestinationFile<>'') {
imagejpeg ($image_p, $DestinationFile, 100);
} else {
header('Content-Type: image/jpeg');
imagejpeg($image_p, null, 100);
};
imagedestroy($image);
imagedestroy($image_p);
};
?>
<img src="<?=$newfilename2?>" border="0"></img>
I'm using it for slightly different purposes (time lapse) but you get an idea. The code is downloading a picture from the camera, saves it as "snapshot.cgi?user=user&pwd=password" file name and then renames it according to a date it was taken. Then a water mark with current time and date is applied.