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 28 29 30 31 32 33 34 35 36 37 38
| <?php
function createImageText($texte,$size)
{
if(ereg('Win32',$_SERVER['SERVER_SOFTWARE']))
{
$font = realpath('..\fonts\DENMARK.TTF');
}
else
{
putenv('GDFONTPATH=' . realpath('./fonts'));
$font = 'DENMARK.TTF';
}
header('Content-type: image/jpeg');
// Longueur du texte
$bbox = imagettfbbox ($size, 0, $font, $texte);
$longueur_texte = $bbox[2] - $bbox[0];
// on créé l'image
$image = imagecreate($longueur_texte,13);
// on applique une couleur de fond
$fond_gris = imagecolorallocate($image, 57, 57, 57);
// on créé la couleur et on l'attribue à une variable pour ne pas la perdre
$textcolor = imagecolorallocate($image, 255, 255, 255);
// Longueur du texte
imagettftext($image, $size, 0, 0, 13, $textcolor, $font, $texte);
//renvoie une image sous format jpeg
return imagejpeg($image,'',100);
imagedestroy($image);
}
createImageText('L\'association','13');
createImageText('Les membres','13');
?> |
Partager