Einzelnen Beitrag anzeigen
  #3  
Alt 28.03.2002, 12:19:11
hawk647 hawk647 ist offline
Anfänger
 
Registriert seit: Mar 2002
Beiträge: 2
FUNCTION Bilder Verkleinern

resizepic($pic_name,$pic_neuer_name,"400","400");


function resizepic($imgfile, $thfile, $max_width="90", $max_height="60") {
list($org_width, $org_height, $orgtype) = getimagesize($imgfile);

if($org_width > $max_width OR $org_height > $max_height){

$div_width = $org_width / $max_width;
$div_height = $org_height / $max_height;

if ($div_width >= $div_height) {
$new_width = $max_width;
$new_height = round($org_height / $div_width);
} else {
$new_height = $max_height;
$new_width = round($org_width / $div_height);
}

switch ($orgtype) {
case 1 :
$im = imagecreatefromgif($imgfile);
break;
case 2 :
$im = imagecreatefromjpeg($imgfile);
break;
case 3 :
$im = imagecreatefrompng($imgfile);
break;
}

if ($im) {
$tn = imagecreate($new_width,$new_height);
if ($tn) {
imagecopyresized($tn,$im,0,0,0,0,$new_width,$new_height,$org_width,$or g_height);
switch ($orgtype){
case 1 :
imagegif($tn,$thfile);
return 1;
break;
case 2 :
imagejpeg($tn,$thfile,80);
return 2;
break;
case 3 :
imagepng($tn,$thfile);
return 3;
break;
}
imagedestroy($tn);
imagedestroy($im);
}
}
}
return false;
}
Mit Zitat antworten