Back to the snippets index

Rotate an image ( Anthony 14/6/2008 )

Rotate an image; again a lot more complicated than using Imagemagick.

GD code:

<?php
// 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);

// Save the image as output.jpg
imagejpeg$rotate"output.jpg" );

// Clear the memory of the tempory image
imagedestroy$canvas );
?>

Change a png to a jpg
Create some text as an image
Crop an image
Display image without saving
Grayscale image
Resize an image
Rotate an image
Watermark an image