PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How can I rotate an image?


Probably not something you will want to do a lot of in ordinary day PHP use, but if you want to rotate an image use the well-named imagerotate function.

This takes the image to rotate, the angle of rotation, and a color to fill the blank space around the rotated image with.

Here's an example:
<?php
$original 
imagecreatefrompng("myimage.png");
$red =  imageColorAllocate($original,255,0,0);
imagerotate($original,50,$red);
header("content-type:image/png");
imagepng($rotated);
imagedestroy($original);
imagedestroy($rotated);
?>



More images PHP Questions

How can I add text to an image?
How can I find the width and height of an image resource?
How can I find the colour of a pixel of an image?