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 39 40 41 42 43 44 45 46 47 48 49
| <?php
//On envoie du PNG au navigateur et non pas du PHP
header ("Content-type: image/png");
// initialisation des variables
$texte = stripslashes($_GET["texte"]);
$texte_encode = urlencode($texte);
$image_path = "/www/html/images_dyn/CACHE_png1/".$texte_encode.".png";
if (file_exists($image_path)) {
readfile($image_path);
}
else
{
// Définission de la variable d'environnement pour GD
putenv('GDFONTPATH=' . realpath('.'));
//Definition des variables internes
$width = 585;
$height = 60;
$font = 'MaiandraGDDemiBold';
$fontsize = 30;
// Creation de l'image et affectations des couleurs
$im = @imagecreate (100, 50) or die ("Impossible d'initialiser la bibliothèque GD");
$im = @imagecreatefrompng ("../images/base_titre_rub.png") or die ("Impossible d'initialiser la bibliothèque GD");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 107, 65, 107);
//Calcul des coordonnees pour centrer le texte
$box = ImageTTFBBox($fontsize, 0, $font, $texte);
$x = ($width - ($box[2] - $box[0])) / 2;
$y = ($height - ($box[1] - $box[7])) / 2;
$y -= $box[7];
// On ecrit le texte, et on ferme..
ImageTTFText ($im, $fontsize, 0, $x, $y, $text_color, $font, $texte);
//imagepng ($im);
imagepng ($im, $image_path);
imagedestroy($im);
};
?> |
Partager