PHP Image rotate

// Set the path to the image to rotate
$input_image = "House.jpg";
//How many degrees you wish to rotate
$degrees = 180;
// Create the canvas
$canvas = imagecreatefromjpeg( $input_image ) ;
// Rotates the image
$rotate = imagerotate( $canvas, $degrees, 0 ) ;
// Save the image as output.jpg
imagejpeg( $rotate, "output.jpg" );
// Clear the memory of the tempory image
imagedestroy( $canvas );