Page 1 of 1

Useful webcam code

Posted: Sun 28 Feb 2010 10:25 am
by RCE
I wanted my weather cam to show more of the weather conditions, and less of the surrounding area. This meant physically turning the webcam into portrait mode, of course the saved images are still displayed in landscape so image is laid on it's side.

Found a javascript utility that manipulates the images http://www.swfir.com/ browser needs to be flash enabled.

Demo of it working at http://www.imagezoom.co.uk/weather/viewcam.htm (note this demo site is only updated once per day).

Re: Useful webcam code

Posted: Sun 28 Feb 2010 12:28 pm
by beteljuice
Does your server support php ?

Assuming a .jpg picture source:
cam.php

Code: Select all

<?php
// cam.php
// File and rotation
$filename = 'test.jpg';
$degrees = 90; // anticlockwise or -90 or 270 for clockwise

// Content type
header('Content-type: image/jpeg');

// Load
$source = imagecreatefromjpeg($filename);

// Rotate
$rotate = imagerotate($source, $degrees, 0);

// Output
imagejpeg($rotate);

imagedestroy($source);
imagedestroy($rotate);
?> 
In your html the code becomes <img src="cam.php" .... etc. />

Re: Useful webcam code

Posted: Sun 28 Feb 2010 3:26 pm
by RCE
No, thanks anyway code may be useful for someone.