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
| $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);
} |
Partager