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 90
|
$requete_temp = "SELECT photo_temp, photo_code FROM t_photos WHERE photo_id=".$_GET["id"];
$photo_temp = mysql_query($requete_temp);
while ($ligne_temp3=mysql_fetch_array($photo_temp))
{
$lien = $ligne_temp3["photo_temp"];
$code = $ligne_temp3["photo_code"];
}
$password_md5 = $code;
$imagename = $lien;
$source = $lien;
$file = $lien;
$resized = $lien;
$th = '../secure_images/'.$password_md5.'_home.jpg';
$wm = '../secure_images/'.$password_md5.'_tarif.jpg';
move_uploaded_file($source, $file);
list($width, $height) = getimagesize($file);
/* Pour l'image resizee */
$modwidth = 401;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $resized, 100);
imagedestroy($image);
/* Pour l'image avec le wm */
list($width, $height) = getimagesize($resized) ;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($resized);
$watermark = imagecreatefrompng('wt.png');
# configuration du canal alpha pour le WM
imagealphablending($watermark,false);
imagesavealpha($watermark,true);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($resized);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
$size = getimagesize($resized);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 60);
imagejpeg($image,$wm,100);
imagedestroy($image);
imagedestroy($watermark);
/* Pour le thumb */
$modwidth = 200;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($wm);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $th, 100);
//unlink($resized);
//unlink($file); |
Partager