PHP Schnipsel

Bild Goessen Limit

Dieses Script begrenzt die Grösse eines Bildes auf die, in der Funktion definierte Grösse.

Drucken
  1.  <?php   
  2.     
  3.  function piclimiter ($bild$size) {   
  4.   $imginfo = @getimagesize($bild);   
  5.      
  6.   if(($imginfo[0] != && $imginfo[0] > $size  
  7.   || ($imginfo[1] != && $imginfo[1] > $size)) {   
  8.    if($size != 0) {    
  9.     $div1 $size $imginfo[0];    
  10.     $div2 $size $imginfo[1];    
  11.    } else {    
  12.     $div1 1  
  13.     $div2 1  
  14.      
  15.    if($div1 $div2) {   
  16.     $imgwidth $size  
  17.     $imgheight round($imginfo[1]*$div1);   
  18.    } else {   
  19.     $imgheight $size  
  20.     $imgwidth round($imginfo[0]*$div2);   
  21.      
  22.     
  23.   $picture '<img src="'.$bild."    
  24.   width="'.$imgwidth.'"    
  25.   height="'.$imgheight.'"    
  26.   border="0">;   
  27.   } else {   
  28.    $picture '<img src="'.$bild.'" border="0">'  
  29.     
  30.   return $picture  
  31.    
  32.     
  33.  //Besipiel   
  34.  echo piclimiter("bild.png""450");   
  35.     
  36.  ?>   






T: 34979 G: 7 H: 10 T: +4 O: 6