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
| <?php
header ("Content-type: image/jpeg"); // L'image que l'on va créer est un jpeg
// On charge d'abord les images
$source = imagecreatefrompng("logosdz.png"); // Le logo est la source
$destination = imagecreatefromjpeg("love.jpg"); // 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 écrit le texte
$orange = imagecolorallocate($destination, 255, 128, 0);
$bleu = imagecolorallocate($destination, 0, 0, 255);
$bleuclair = imagecolorallocate($destination, 156, 227, 254);
$noir = imagecolorallocate($destination, 0, 0, 0);
$blanc = imagecolorallocate($destination, 255, 255, 255);
$font = 'tahoma.ttf';
imagettftext($destination,44, 0, 105, 225, $blanc, $font, "Texte");
// 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;
// On met le logo (source) dans l'image de destination (la photo)
imagecopymerge($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source, 60);
// On affiche l'image de destination qui a été fusionnée avec le logo
imagejpeg($destination);
?> |
Partager