Hej
<?php
$img_w = (isset($_GET["w"]) && $_GET["w"]!=0) ? abs(intval($_GET["w"])) : 25;
$img_h = (isset($_GET["h"]) && $_GET["h"]!=0) ? abs(intval($_GET["h"])) : 115;
$img_t = (isset($_GET["t"]) && $_GET["t"]!="") ? $_GET["t"] : "Ingen parametre";
$img = imagecreate($img_w,$img_h);
$img_bg = imagecreatefromgif("_img/button_bg.gif");
$img_left = imagecreatefromgif("_img/button_left.gif");
$img_right = imagecreatefromgif("_img/button_right.gif");
imagesettile($img,$img_bg);
imagefilledrectangle($img,0,0,$img_w,$img_h,IMG_COLOR_TILED);
imagecopy($img,$img_left,0,0,0,0,imagesx($img_left),imagesy($img_left));
imagecopy($img,$img_right,imagesx($img)-imagesx($img_right),0,0,0,imagesx($img_right),imagesy($img_right));
$ft_size = 1;
while(true) {
$corners = imagettfbbox($ft_size+1,0,"arial.ttf",$img_t);
$c_x1 = $corners[0];
$c_y1 = $corners[1];
$c_x2 = $corners[2];
$c_y2 = $corners[3];
$c_x3 = $corners[4];
$c_y3 = $corners[5];
$c_x4 = $corners[6];
$c_y4 = $corners[7];
if(abs($c_x3-$c_x1)<imagesx($img)-8
&& abs($c_y3-$c_y1)<imagesy($img)-8) {
$ft_size++;
} else {
break;
}
}
$corners = imagettfbbox($ft_size,0,"arial.ttf",$img_t);
$c_x1 = $corners[0];
$c_y1 = $corners[1];
$c_x2 = $corners[2];
$c_y2 = $corners[3];
$c_x3 = $corners[4];
$c_y3 = $corners[5];
$c_x4 = $corners[6];
$c_y4 = $corners[7];
$x = intval(imagesx($img)/2 - abs($c_x3-$c_x1)/2 + 1);
$y = intval(imagesy($img)/2 + abs($c_y3-$c_y1)/2 - 1);;
imagettftext($img,$ft_size,0,$x,$y,imagecolorallocate($img,51,51,51),"arial.ttf",$img_t);
header('Content-type: image/gif');
imagegif($img);
imagedestroy($img);
imagedestroy($img_bg);
imagedestroy($img_left);
imagedestroy($img_right);
?>
Ovenstående bruger jeg til at tegne en menu knap men nogle gange kommer der 'pletter' på knappen. Hvordan undgår jeg det?