Home > php教程 > PHP源码 > body text

php 将图片旋转90度

PHP中文网
Release: 2016-05-25 17:06:50
Original
1448 people have browsed it


/**
  * 修改一个图片 让其翻转指定度数
  * 
  * @param string  $filename 文件名(包括文件路径)
  * @param  float $degrees 旋转度数
  * @return boolean
  * @author zhaocj
  */
   function  flip($filename,$src,$degrees = 90)
 {
  //读取图片
  $data = @getimagesize($filename);
  if($data==false)return false;
  //读取旧图片
  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;
 }
Copy after login

                   

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template