1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<?p
$font = "consola.ttf";
$box = imagettfbbox ($size, 0, $font, $text);
$tW = $box[2] - $box[0];
$tH= $box[3]-$box[5];
$margex = 5;
$margey = 10;
$width = $tW+$margex;
$height= $tH+$margey;
$textx = ($margex-2)/2;
$texty = $height - $margey;
$img = imagecreatetruecolor($width,$height);
$blanc = imagecolorallocate($img,255,255,255);
$noir = imagecolorallocate($img,0,0,0);
imagefill($img,0,0,$blanc);
imagettftext($img, $size, 0, $textx, $texty, $noir, $font, $text);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?> |
Partager