Php rotating images 90 degrees, the method is very simple, let's look at the function directly
The Code is as follows:
/**
* Modify an image to flip it to a specified degree
*
* @ Param string $ filename file name (including file path)
* @ Param float $ degrees rotation degree
* @ Return boolean
*/
Function flip ($ filename, $ src, $ degrees = 90)
{
// Read the image
$ Data = @ getimagesize ($ filename );
If ($ data = false) return false;
// Read the old image
Switch ($ data [2]) {
Case 1:
$ Src_f = imagecreatefromgif ($ filename); break;
Case 2:
$ Src_f = imagecreatefromjpeg ($ filename); break;
Case 3:
$ Src_f = imagecreatefrompng ($ filename); break;
}
If ($ src_f = "") return false;
$ Rotate = @ imagerotate ($ src_f, $ degrees, 0 );
If (! Imagejpeg ($ rotate, $ src, 100) return false;
@ Imagedestroy ($ rotate );
Return true;
}