Home >Backend Development >PHP Tutorial >How to rotate an image 90 degrees in PHP_PHP Tutorial

How to rotate an image 90 degrees in PHP_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:25:31803browse

Copy code The code is as follows:

/**
* Modify an image to flip the specified degree
*
* @param string $filename file name (including file path)
* @param float $degrees rotation degrees
* @return boolean
*/
function flip($filename,$src,$ degrees = 90)
{
//Read the image
$data = @getimagesize($filename);
if($data==false)return false;
//Read 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;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825070.htmlTechArticleCopy the code The code is as follows: /** * Modify an image to flip it by a specified degree* * @param string $filename File name (including file path) * @param float $degrees Rotation degrees * @r...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn