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 50 51 52 53 54 55
|
function ajoutfiligrane($img_destination)
{
// On charge d'abord les images
$source = imagecreatefrompng("images/images/logo-proof.png");
//Infos sur les images
list($largeur_source, $hauteur_source, $type_source, $txtalt_source) = getimagesize($source);
list($largeur_destination, $hauteur_destination, $type_destination, $txtalt_destination) = getimagesize($img_destination);
//En fonction de l'extension
if($type_destination == 2)
{
$destination = imagecreatefromjpeg($img_destination);
}
elseif($type_destination == 3)
{
$destination = imagecreatefrompng($img_destination);
}
elseif($type_destination == 1)
{
$destination = imagecreatefromgif($img_destination);
}
else
{
die();
}
// 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);
if($type_destination == 2)
{
imagejpeg($destination);
}
elseif($type_destination == 3)
{
imagepng($destination);
}
elseif($type_destination == 1)
{
imagegif($destination);
}
else
{
die();
}
} |
Partager