/**
     * 图片旋转处理
     * @param  string  $src 图片本地路径
     * @param  integer $degrees 旋转角度,90逆时针旋转90度,-90顺时针旋转90度
     */
    public function imgturn($src,$degrees)
    {
        $ext = pathinfo($src)['extension'];
        switch ($ext) {
            case 'gif':
                $img = imagecreatefromgif($src);
                $img2 = imagerotate($img, $degrees, 0);//旋转图片
                imagegif($img2, $src, 100);
                break;
            case 'jpg':
            case 'jpeg':
                $img = imagecreatefromjpeg($src);
                $img2 = imagerotate($img, $degrees, 0);//旋转图片
                imagejpeg($img2, $src, 100);
                break;
            case 'png':
                $img = imagecreatefrompng($src);
                /*获取大小*/
                $width = imagesx($img);
                $height = imagesy($img);
                $img2 = imagecreatetruecolor($width, $height);
                //上色 
                $color=imagecolorallocate($img2,255,255,255); 
                //设置透明 
                imagecolortransparent($img2,$color); 
                imagefill($img2,0,0,$color);
                if($degrees==-90){
                    //顺时针旋转90度
                     for ($x = 0; $x < $width; $x++) {
                        for($y=0;$y<$height;$y++) {
                            imagecopy($img2, $img, $height-1-$y,$x, $x, $y, 1, 1);
                        }
                    }
                }
                if($degrees==90){
                    //逆时针旋转90度
                    for ($x = 0; $x < $height; $x++) {
                        for($y=0;$y<$width;$y++) {
                            imagecopy($img2, $img, $x, $y, $width-1-$y, $x, 1, 1);
                        }
                    }  
                }
                imagepng($img2,$src);
                break;
            default:
                die('图片格式错误!');
                break;
        }
        imagedestroy($img);
        imagedestroy($img2);
    }                










