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);
?> |
Partager