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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
| <?php
session_start();
if ($_SESSION['tabimg'] != '')
{
$image = $_SESSION['tabimg'][$_SESSION['imgcur'] -1];
}
else
{
$MyDirectory = opendir('./') or die('Erreur');
$i=0;
while($Entry = @readdir($MyDirectory))
{
if(!is_dir($Directory.'/'.$Entry)) {
if (stripos($Entry,'jpg'))
{
$tabimg[] = $Entry;//nom du fichier jpeg
$i++;
}
}
$_SESSION['tabimg'] = $tabimg;
$_SESSION['nbimage'] = $i;
$_SESSION['imgcur'] = 1;
$image = $_SESSION['tabimg'][$_SESSION['imgcur'] -1];
}
closedir($MyDirectory);
}
header("Content-type: image/jpeg");
$quality = $_GET['quality'];
$varStatic = $_GET['varStatic'];//
$jpeg = imagecreatefromjpeg($image);
list($width, $height) = getimagesize($image);
$image_p = imagecreatetruecolor(800, 800);
imagecopyresampled($image_p, $jpeg, 0, 0, 0, 0, 800, 800, $width, $height);
$green = imagecolorallocate($image_p, 70, 169, 70);
//die($_SESSION);
if ($_SESSION['negatif'] == 1)
imagefilter($image_p,IMG_FILTER_NEGATE);
switch($_GET['action'])
{
case 'flipH':// inversion horizontal de l'image
$width = imagesx($image_p);
$height = imagesy($image_p);
$dest = imagecreatetruecolor($width, $height);
$dest2 = imagecreatetruecolor($width, $height);
imagecopyresampled( $dest2,$image_p, 0, 0, 0, 0, 800, 800, $width, $height);
if ( !isset($_SESSION['Horizontal']) )//je teste si la variable de session 'Horizontal' existe, si elle n'existe pas je la crée (initialisation).
$_SESSION['Horizontal'] = 1;
else //Si elle existe je l'incrémente de 1.
$_SESSION['Horizontal']+=1;
if (($_SESSION['Horizontal'])%2!= 0)
{
for($i=0;$i<$height;$i++)
{
imagecopy($dest, $image_p, 0, ($height - $i - 1), 0, $i, $width, 1);
}
imagecopyresampled($image_p, $dest, 0, 0, 0, 0, 800, 800, $width, $height);
}
else
{
for($i=0;$i<$height;$i++)
{
imagecopy( $image_p,$dest2, 0, ($height - $i - 1), 0, $i, $width, 1);
}
imagecopyresampled($image_p, $dest2, 0, 0, 0, 0, 800, 800, $width, $height);
}
/*for($i=0;$i<$height;$i++)
{
imagecopy($dest, $image_p, 0, ($height - $i - 1), 0, $i, $width, 1);
}
imagecopyresampled($image_p, $dest, 0, 0, 0, 0, 800, 800, $width, $height);*/
break;
case 'rotate':// flip horizontal(le bas de l'image passe en haut et vis versa)
if ( !isset($_SESSION['rotation']) )//je test si la variable de session 'rotation' existe, si elle n'existe pas je la crée (initialisation).
$_SESSION['rotation'] = 1;
else //Si elle existe je l'incrémente de 1.
$_SESSION['rotation']+=1;
//How many degrees you wish to rotate
$degrees = (180*$_SESSION['rotation'])%360;//changement de $degree en multipliant avec $_SESSION['rotation']
// This sets the image type to .jpg but can be changed to png or gif
header('Content-type: image/jpeg') ;
$image_p = imagerotate($image_p, $degrees , 0) ;
break;
default:
break;
} |