
Bild Goessen Limit
Dieses Script begrenzt die Grösse eines Bildes auf die, in der Funktion definierte Grösse.
|
|
<?php
function piclimiter ($bild, $size) {
$imginfo = @getimagesize($bild);
if(($imginfo[0] != 0 && $imginfo[0] > $size)
|| ($imginfo[1] != 0 && $imginfo[1] > $size)) {
if($size != 0) {
$div1 = $size / $imginfo[0];
$div2 = $size / $imginfo[1];
} else {
$div1 = 1;
$div2 = 1;
}
if($div1 < $div2) {
$imgwidth = $size;
$imgheight = round($imginfo[1]*$div1);
} else {
$imgheight = $size;
$imgwidth = round($imginfo[0]*$div2);
}
$picture = '<img src="'.$bild."
width="'.$imgwidth.'"
height="'.$imgheight.'"
border="0">;
} else {
$picture = '<img src="'.$bild.'" border="0">';
}
return $picture;
}
//Besipiel
echo piclimiter("bild.png", "450");
?>
|
T: 34979 G: 7 H: 10 T: +4 O: 6
|
|