L’altre dia vaig haver de fer un script en PHP que generes un boto amb el text que se li passés com a paràmetre. D’aquesta manera tenim una imatge amb el boto i amb aquest simple script li posem el text que volguem. Per insertar-ho en HTML simplement <img alt=’Text alternatiu’ src=’boto.php?text=texte del boto’/>:
Header(“Content-type: image/gif”);
$font=2;
$text=”hola”;
if ( isSet( $_REQUEST[“text”] ) ) $text=$_REQUEST[“text”];
$im = imagecreatefromgif(“boto.gif”);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$font_height = ImageFontHeight( $font );
$font_width = ImageFontWidth( $font );
$image_height = ImageSY($im);
$image_width = ImageSX($im);
$length = $font_width * strlen($text);
$image_center_x = ($image_width/2)-($length/2);
$image_center_y = ($image_height/2)-($font_height/2);
ImageString($im, $font, $image_center_x, $image_center_y, $text, $black);
imagegif($im);
?>
Aquí teniu la imatge del boto que feia servir: