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
| function generer($image, $fonte, $texte, $fichier) {
$image= imagecreatefrompng($image);
$bb=imageftbbox(FONT_SIZE, 0, $fonte, $texte);
$dx= abs($bb[4]-$bb[0]);
$couleur = imagecolorexact($image, "255", "255", "255");
if($dx>MAX_X) {
list($texte1, $texte2)= couper($texte);
$bb1=imageftbbox(FONT_SIZE, 0, $fonte, $texte1);
$bb2=imageftbbox(FONT_SIZE, 0, $fonte, $texte2);
$dx1= abs($bb1[4]-$bb1[0]);
$dx2= abs($bb2[4]-$bb2[0]);
$x1=X0-0.5*$dx1;
$x2=X0-0.5*$dx2;
imagefttext($image, FONT_SIZE, 0, $x1, Y1, $couleur, $fonte, $texte1);
imagefttext($image, FONT_SIZE, 0, $x2, Y2, $couleur, $fonte, $texte2);
} else {
$x=X0-0.5*$dx;
imagefttext($image, FONT_SIZE, 0, $x, Y0, $couleur, $fonte, $texte);
}
imagepng($image, $fichier);
//imagedestroy($image);
} |
Partager