mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
made problems with GD non-lethal
git-svn-id: https://svn.fhem.de/fhem/trunk@1557 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1f688078ba
commit
b9356b665b
@ -320,59 +320,65 @@ RSS_returnJPEG($) {
|
|||||||
my $S= GD::Image->newTrueColor($width,$height);
|
my $S= GD::Image->newTrueColor($width,$height);
|
||||||
$S->colorAllocate(0,0,0); # black is the background
|
$S->colorAllocate(0,0,0); # black is the background
|
||||||
|
|
||||||
#
|
# wrap to make problems with GD non-lethal
|
||||||
# set the background
|
|
||||||
#
|
|
||||||
# check if background directory is set
|
|
||||||
my $bgdir= AttrVal($name,"bg","");
|
|
||||||
goto SKIPBG unless($bgdir ne "");
|
|
||||||
|
|
||||||
my $bgnr; # item number
|
eval {
|
||||||
if(defined($defs{$name}{fhem}) && defined($defs{$name}{fhem}{bgnr})) {
|
|
||||||
$bgnr= $defs{$name}{fhem}{bgnr};
|
#
|
||||||
} else {
|
# set the background
|
||||||
$bgnr= 0;
|
#
|
||||||
}
|
# check if background directory is set
|
||||||
# check if at least tmin seconds have passed
|
my $bgdir= AttrVal($name,"bg","");
|
||||||
my $t0= 0;
|
goto SKIPBG unless($bgdir ne "");
|
||||||
my $tmin= AttrVal($name,"tmin",0);
|
|
||||||
if(defined($defs{$name}{fhem}) && defined($defs{$name}{fhem}{t})) {
|
my $bgnr; # item number
|
||||||
$t0= $defs{$name}{fhem}{t};
|
if(defined($defs{$name}{fhem}) && defined($defs{$name}{fhem}{bgnr})) {
|
||||||
}
|
$bgnr= $defs{$name}{fhem}{bgnr};
|
||||||
my $t1= time();
|
|
||||||
if($t1-$t0>= $tmin) {
|
|
||||||
$defs{$name}{fhem}{t}= $t1;
|
|
||||||
$bgnr++;
|
|
||||||
}
|
|
||||||
# detect pictures
|
|
||||||
goto SKIPBG unless(opendir(BGDIR, $bgdir));
|
|
||||||
my @bgfiles= grep {$_ !~ /^\./} readdir(BGDIR);
|
|
||||||
closedir(BGDIR);
|
|
||||||
# get item number
|
|
||||||
if($#bgfiles>=0) {
|
|
||||||
if($bgnr > $#bgfiles) { $bgnr= 0; }
|
|
||||||
$defs{$name}{fhem}{bgnr}= $bgnr;
|
|
||||||
my $bgfile= $bgdir . "/" . $bgfiles[$bgnr];
|
|
||||||
my $bg= newFromJpeg GD::Image($bgfile);
|
|
||||||
my ($bgwidth,$bgheight)= $bg->getBounds();
|
|
||||||
my ($w,$h);
|
|
||||||
my ($u,$v)= ($bgwidth/$width, $bgheight/$height);
|
|
||||||
if($u>$v) {
|
|
||||||
$w= $width;
|
|
||||||
$h= $bgheight/$u;
|
|
||||||
} else {
|
} else {
|
||||||
$h= $height;
|
$bgnr= 0;
|
||||||
$w= $bgwidth/$v;
|
|
||||||
}
|
}
|
||||||
$S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight);
|
# check if at least tmin seconds have passed
|
||||||
}
|
my $t0= 0;
|
||||||
SKIPBG:
|
my $tmin= AttrVal($name,"tmin",0);
|
||||||
|
if(defined($defs{$name}{fhem}) && defined($defs{$name}{fhem}{t})) {
|
||||||
|
$t0= $defs{$name}{fhem}{t};
|
||||||
|
}
|
||||||
|
my $t1= time();
|
||||||
|
if($t1-$t0>= $tmin) {
|
||||||
|
$defs{$name}{fhem}{t}= $t1;
|
||||||
|
$bgnr++;
|
||||||
|
}
|
||||||
|
# detect pictures
|
||||||
|
goto SKIPBG unless(opendir(BGDIR, $bgdir));
|
||||||
|
my @bgfiles= grep {$_ !~ /^\./} readdir(BGDIR);
|
||||||
|
closedir(BGDIR);
|
||||||
|
# get item number
|
||||||
|
if($#bgfiles>=0) {
|
||||||
|
if($bgnr > $#bgfiles) { $bgnr= 0; }
|
||||||
|
$defs{$name}{fhem}{bgnr}= $bgnr;
|
||||||
|
my $bgfile= $bgdir . "/" . $bgfiles[$bgnr];
|
||||||
|
my $bg= newFromJpeg GD::Image($bgfile);
|
||||||
|
my ($bgwidth,$bgheight)= $bg->getBounds();
|
||||||
|
my ($w,$h);
|
||||||
|
my ($u,$v)= ($bgwidth/$width, $bgheight/$height);
|
||||||
|
if($u>$v) {
|
||||||
|
$w= $width;
|
||||||
|
$h= $bgheight/$u;
|
||||||
|
} else {
|
||||||
|
$h= $height;
|
||||||
|
$w= $bgwidth/$v;
|
||||||
|
}
|
||||||
|
$S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight);
|
||||||
|
}
|
||||||
|
SKIPBG:
|
||||||
|
|
||||||
#
|
#
|
||||||
# evaluate layout
|
# evaluate layout
|
||||||
#
|
#
|
||||||
RSS_evalLayout($S, $name, $defs{$name}{fhem}{layout});
|
RSS_evalLayout($S, $name, $defs{$name}{fhem}{layout});
|
||||||
|
|
||||||
|
}; warn $@ if $@;
|
||||||
|
|
||||||
#
|
#
|
||||||
# return jpeg image
|
# return jpeg image
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user