Kevin Heidrich: Wieder Images unter PHP

Beitrag lesen

Hallöchen

sind unterschiedlich,  und das macht auch den sichtbaren >Unterschied aus. Aber bei solchen Fragen nutzt es wenig, sich eine >URL anzuschauen, man müßte dein PHP-Script

Das ganze besteht aus zwei Dateien...

Einmal:
---------------------------------------------------
blah,blah

Diese Skript erzeugt Bilder als Schaltfläche:
<p>
<img src="genbutton.php?s=18&font=5&text=Homepage&color=red">
   
<img src="genbutton.php?s=18&font=6&text=Homepage&color=green">
   
<img src="genbutton.php?s=18&font=3&text=Homepage&color=blue">
</div>

blah,blah
-----------------------------------------
Und
-------------------------------------

<?php
header( "Content-type: image/png");
if (!isset($s)) $s=11;

if (!isset($staticwidth)){
      $dx=(imageFontwidth($font)*strlen($text));
} else {
      $dx=$staticwidth;
}

$dy=imageFontHeight($font) + 6;
 $xpad=10;
 $ypad=10;

$im=imagecreate($dx+$xpad,$dy+$ypad);

if ($color== "blue") {
    $fgcolor=ImageColorAllocate($im, 0,0,255);
 } elseif ($color== "red") {
    $fgcolor=ImageColorAllocate($im, 255,0,0);
 } elseif ($color== "green") {
    $fgcolor=ImageColorAllocate($im, 0,255,0);
 } else {
 $fgcolor=ImageColorAllocate($im, $color[0],$color[1],$color[2]);
 }

$black=ImageColorAllocate($im, 0,0,0);
 $white=ImageColorAllocate($im,255,255,255);

ImageRectangle($im, 0, 0, $dx+$xpad-2, $dy+$ypad-2, $black);
 ImageRectangle($im, 0, 0, $dx+$xpad, $dy+$ypad, $white);

Imagestring($im, $font, (int)($xpad*.80), $dy-(int)($ypad)-1, $text, $black);

ImagePng($im);
 ImageDestroy($im);
?>

-----------------------------------

Ich hab das ganze nochmal verglichen.... die Datei sind gleich!
Diese Datei kommen aus einem Buch von Jörg Krause...
Vielleicht kennt das ja jemand von euch!