bonjour tous le monde,
en fait j'essaie de faire une affiche personnaliser par les clients(visiteur site web) avec la librairy GD,
mais j'ai confronté un probléme que j'ai pas pu résolu depuis 3 jour,
aprés que le client saisi son adresse je l'ecris sur l'affiche sur la zone positionner déja mais le probléme c'est que q'on il a taper un grand adresse il sort de l'affiche(text dehors) , je cherche une fonctionne qui retour a la ligne que le text eteint la limit de l'image
Merci d'avance et voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php
header ("Content-type: image/png");
$adresse=$_POST['adresse'];
$cp=$_POST['cp'];
$ville=$_POST['ville'];
$tel=$_POST['tel'];
$email=$_POST['email'];
$site=$_POST['site'];
// On charge d'abord les images
$source = imagecreatefrompng("Logos/logoIvoire.png"); // Le logo est la source
$destination = imagecreatefrompng("images/yellow_shirt/front/affiche1.png"); // La photo est la destination
 
// Les fonctions imagesx et imagesy renvoient la largeur et la hauteur d'une image
$largeur_source = imagesx($source);
$hauteur_source = imagesy($source);
$largeur_destination = imagesx($destination);
$hauteur_destination = imagesy($destination);
 
// On veut placer le logo en bas à droite, on calcule les coordonnées où on doit placer le logo sur la photo
$destination_x = $largeur_destination - $largeur_source;
$destination_y =  $hauteur_destination - $hauteur_source;
 
/*ecrire sur une photos */
$blanc = imagecolorallocate($destination, 255, 255, 255);
$noir = imagecolorallocate($destination, 0, 0, 0);
 
imagestring($destination, 4, $largeur_destination-210, $destination_y-50, $adresse, $noir);
imagestring($destination, 4, $largeur_destination-210, $destination_y-30, $cp, $noir);
imagestring($destination, 4, $largeur_destination-160, $destination_y-30, $ville, $noir);
imagestring($destination, 4, $largeur_destination-210, $destination_y-10, $tel, $noir);
imagestring($destination, 4, $largeur_destination-210, $destination_y+10, $email, $noir);
imagestring($destination, 4, $largeur_destination-210, $destination_y+30,$site, $noir);
 
/* fin ecrire sur une photos */
 
// On met le logo (source) dans l'image de destination (la photo)
imagecopymerge($destination, $source, $destination_x-195, $destination_y-180, 0, 0, $largeur_source, $hauteur_source, 60);
 
// On affiche l'image de destination qui a été fusionnée avec le logo
//imagepng($destination,'Logos/imageTestGD.jpg');
imagepng($destination);
 
imagedestroy($im);
?>