Skip to content

Commit 1305558

Browse files
committed
Add webcam upload script
1 parent 03a309f commit 1305558

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

bin/webcam.pl

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env perl
2+
3+
=pod
4+
Wihlo - Web-based weather logging and display software
5+
Copyright (C) 2015 A Beverley
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Affero General Public License as
9+
published by the Free Software Foundation, either version 3 of the
10+
License, or (at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Affero General Public License for more details.
16+
17+
You should have received a copy of the GNU Affero General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
=cut
20+
21+
use FindBin;
22+
use lib "$FindBin::Bin/../lib";
23+
24+
use Dancer2;
25+
use Dancer2::Plugin::DBIC qw(schema resultset rset);
26+
use DateTime;
27+
use Image::Magick;
28+
use LWP::Simple qw//;
29+
use Wihlo::Schema;
30+
31+
my $image = LWP::Simple::get("http://192.168.1.201/img/snapshot.cgi");
32+
33+
my $imgm = Image::Magick->new(magick => 'jpg');
34+
$imgm->BlobToImage($image);
35+
$imgm->Resize(width => '64', height => '64');
36+
$imgm->write(filename => 'xx.jpg');
37+
my $thumbnail = $imgm->ImageToBlob;
38+
39+
rset('Webcam')->create({
40+
time => DateTime->now,
41+
image => $image,
42+
thumbnail => $thumbnail,
43+
});
44+
45+
1;

0 commit comments

Comments
 (0)