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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<?php
require_once("bdd.php");
if(session_is_registered("login")) {
$pseudo = $_SESSION['login'] ;
$id_gal = $_GET['id_gal'];
$id_photo = $_GET['id_photo'];
$font = './arial.ttf';
//$font2 = './baloney_.ttf';
//$font3 = './vladimir.ttf';
//on recupere le repertoire des photo
$sql_rep1 = "SELECT dossier_album FROM galerie WHERE id='$id_gal'";
$req_rep1 = mysql_query($sql_rep1) or die('Erreur SQL !<br>'.$sql_re1p.'<br>'.mysql_error());
$data_rep1 = mysql_fetch_array($req_rep1);
$repertoire = $data_rep1['dossier_album'];
//on recupere l'image
$sql_photo1 = "SELECT photo,vue FROM galerie WHERE id='$id_photo'";
$req_photo1 = mysql_query($sql_photo1) or die('Erreur SQL !<br>'.$sql_photo1.'<br>'.mysql_error());
$data_photo1 = mysql_fetch_array($req_photo1);
$lien_image = "images/photos/".$repertoire."/".$data_photo1['photo'];
header ("Content-type: image/jpeg"); // L'image que l'on va créer est un jpeg
// On charge d'abord les images
$source = imagecreatefrompng("images/divers/logo.png"); // Le logo est la source
$destination = imagecreatefromjpeg($lien_image); // La photo est la destination
// variable pour le texte de l image
$rouge = imagecolorallocate($destination, 255, 0, 0);
$blanc = imagecolorallocate($destination, 255, 255, 255);
$grey = imagecolorallocate($destination, 128, 128, 128);
$black = imagecolorallocate($destination, 0, 0, 0);
$text_vue = "Photo Vue $data_photo1[vue] fois";
$text = "Axel - Photo Album";
$ref = $id_photo."".$id_gal."_".$repertoire."_".$data_photo1['photo'];
$extention = array(".JPG", ".jpg", ".jpeg", ".JPEG");
$ref = str_replace($extention, "", $ref);
$autorisation = "Autorisation d'affichage accordé à $pseudo";
$identification = "N° d'autorisation : ".date("Ymd").".$ip.".date("siH") ;
// 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;
// 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, 50);
// On ecrit sur l image
imagettftext($destination, 12, 0, 14, 15, $black, $font, $autorisation);
imagettftext($destination, 12, 0, 16, 15, $black, $font, $autorisation);
imagettftext($destination, 12, 0, 15, 14, $black, $font, $autorisation);
imagettftext($destination, 12, 0, 15, 16, $black, $font, $autorisation);
imagettftext($destination, 12, 0, 15, 15, $blanc, $font, $autorisation);
imagettftext($destination, 12, 0, 15, 29, $black, $font, $ref);
imagettftext($destination, 12, 0, 15, 31, $black, $font, $ref);
imagettftext($destination, 12, 0, 14, 30, $black, $font, $ref);
imagettftext($destination, 12, 0, 16, 30, $black, $font, $ref);
imagettftext($destination, 12, 0, 15, 30, $blanc, $font, $ref);
imagettftext($destination, 12, 0, 15, 44, $black, $font, $identification);
imagettftext($destination, 12, 0, 15, 46, $black, $font, $identification);
imagettftext($destination, 12, 0, 14, 45, $black, $font, $identification);
imagettftext($destination, 12, 0, 16, 45, $black, $font, $identification);
imagettftext($destination, 12, 0, 15, 45, $blanc, $font, $identification);
imagettftext($destination, 12, 0, 15, 59, $blanc, $font, $text_vue);
imagettftext($destination, 12, 0, 15, 61, $blanc, $font, $text_vue);
imagettftext($destination, 12, 0, 14, 60, $blanc, $font, $text_vue);
imagettftext($destination, 12, 0, 16, 60, $blanc, $font, $text_vue);
imagettftext($destination, 12, 0, 15, 60, $rouge, $font, $text_vue);
imagettftext($destination, 40, 0, 15, $hauteur_destination - 10, $blanc, $font, "N°".$id_photo);
//imagestring($destination, 3, 15, $hauteur_destination - 20 ,$ref, $blanc);
//imagestring($destination, 3, 15, $hauteur_destination - 30 ,$text_vue, $blanc);
// On affiche l'image final
imagejpeg($destination);
imagedestroy($destination);
}
?> |
Partager