Snippets - GD

Snippets index page

Rotate an image - Anthony 14/6/2008

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

  1. <?php
  2. // Set the path to the image to rotate
  3. $input_image "House.jpg";
  4. //How many degrees you wish to rotate
  5. $degrees 180;
  6. // Create the canvas
  7. $canvas imagecreatefromjpeg$input_image ) ;
  8. // Rotates the image
  9. $rotate imagerotate$canvas$degrees) ;
  10. // Save the image as output.jpg
  11. imagejpeg$rotate"output.jpg" );
  12. // Clear the memory of the tempory image
  13. imagedestroy$canvas );
  14. ?>

For more examples and information check out the main Imagemagick section.

Change a png to a jpg View

Create some text as an image View

Crop an image View

Display image without saving View

Grayscale image View

Resize an image View

Rotate an image View

Watermark an image View