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
| <?php
session_start();
if ( !isset($_SESSION['rotation']) )
$_SESSION['rotation'] = 1;
else
$_SESSION['rotation']+=1;
// The file you are rotating
$image = 'test1.jpg';
//How many degrees you wish to rotate
$degrees = (90*$_SESSION['rotation'])%360;
// This sets the image type to .jpg but can be changed to png or gif
header('Content-type: image/jpeg') ;
// Create the canvas
$source = imagecreatefromjpeg($image) ;
// Rotates the image
$rotate = imagerotate($source, $degrees, 0) ;
// Outputs a jpg image, you could change this to gif or png if needed
imagejpeg($rotate) ;
?> |