//* w= : Breite des neuen Bildes (x/y-Verhältnis wird beibehalten) //* h= : Höhe des neuen Bildes (x/y-Verhältnis wird beibehalten) // Es sollte entweder w oder h angegeben werden ! //* lupe=1 : Es wird eine Lupe ins Bild eingeblendet //* cuty=p : Das Bild in der Höhe auf p Pixel unten abgeschnitten //* dest= : format des Ausgabebildes (dest=gif/png/jpeg) default : Ausgabeformat=Eingabeformat // src= : Bildquelle // Die mit * gekennzeichneten Parameter sind optinional //=============================================================================================== function PNGSupport() { $browser=getenv("HTTP_USER_AGENT"); if (strrpos($browser,"Konquerror")) return true; return false; } function errorMsg() { $im = ImageCreateTrueColor (150, 30); /* Create a blank image */ $bgc = ImageColorAllocate ($im, 255, 255, 255); $tc = ImageColorAllocate ($im, 0, 0, 0); ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc); return $im; } function LoadPic($imgname) { global $dest; $im = @ImageCreateFromJPEG ($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = @ImageCreateFromGIF ($imgname); /* Attempt to open */ if (!$im) { $im = @ImageCreateFromPNG ($imgname); /* Attempt to open */ if (!$im) { $im=errorMsg(); } else $dest="png"; } else $dest="gif"; } else $dest="jpg"; return $im; } function thubnail($img,$w,$h,$lupe) { $width=imagesx($img); $height=imagesy($img); if (($w>0)||($h>0)) { if ($w==0) { $w=($h/$height)*$width; } else { $h=($w/$width)*$height; } $new=ImageCreateTrueColor($w,$h); imagecopyresized ($new,$img, 0, 0, 0, 0, $w, $h, $width, $height ); imagedestroy($img); if ($lupe==1) { $col1=imagecolorclosest($new,0,0,0); $col0=imagecolorclosest($new,255,255,255); imagefilledrectangle($new,$w-15,$h-15,$w,$h,$col0); imagearc($new,$w-10,$h-10,9,9,0,359,$col1); imageline($new,$w-6,$h-6,$w,$h,$col1); } return $new; } return $img; } //======================================== $img = LoadPic("$src"); if (!isset($h)) $h=0; if (!isset($w)) $w=0; if (!isset($lupe)) $lupe=0; if (($w>0)||($h>0)) { $img=thubnail($img,$w,$h,$lupe); } if ($dest=="gif") if (PNGSupport()) $dest="png"; else if (($dest=="png")&&(!PNGSupport())) $dest="gif"; // ImageString ($img, 1, 0, 0, "$dest", imagecolorclosest($img,255,0,0) ); if (isset($cuty)) { $imagew=imagesx($img); $img2=ImageCreateTrueColor($imagew,$cuty); ImageCopy($img2,$img,0,0 ,0,0, $imagew,$cuty); $img=$img2; } header ("Content-type: image/$dest"); if ($dest=="jpg") ImageJPEG($img,"",60); if ($dest=="png") ImagePNG($img); if ($dest=="gif") ImageGIF($img); ImageDestroy($img); ?>