You can use this for rotate image
$image = 'images/me.jpg';
// Set the path to the image to rotate
$input_image = $image;
//How many degrees you wish to rotate
$degrees = 90;
// Create the canvas
$info = getimagesize($image);
if($info['mime']) {
if($info['mime']=='image/gif'){
$canvas = imagecreatefromgif($image);
// Rotates the image
$rotate = imagerotate( $canvas, $degrees, 0 ) ;
// Save the image as output.jpg
imagegif( $rotate, $image );
}elseif($info['mime']=='image/jpeg'){
$canvas = imagecreatefromjpeg($image);
// Rotates the image
$rotate = imagerotate( $canvas, $degrees, 0 ) ;
// Save the image as output.jpg
imagejpeg( $rotate, $image );
}elseif($info['mime']=='image/png'){
$canvas = imagecreatefrompng($image);
// Rotates the image
$rotate = imagerotate( $canvas, $degrees, 0 ) ;
// Save the image as output.jpg
imagepng( $rotate, $image );
}
}
// Clear the memory of the tempory image
imagedestroy( $canvas );
?>
<img src="<?=$image?>">