代码
private function flip($filename='',$src='',$degrees = 90)
{
if(!$filename || !file_exists($filename) || !$src || !file_exists($src)){
return false;
}
$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;
}