Ejemplo n.º 1
0
 public function rotate($degree, $color = array(255, 255, 255))
 {
     if (!function_exists('imagerotate')) {
         throw new ImageUtilityException('ImageGdUtility 錯誤!', '尚未找尋到 imagerotate 函式!', '請確認 GD 函式庫中是否有支援 imagerotate 函式!');
     }
     if (!is_numeric($degree)) {
         throw new ImageUtilityException('ImageGdUtility 錯誤!', '角度一定要是數字,degree:' . $degree, '請確認 GD 函式庫中是否有支援 imagerotate 函式!');
     }
     if (!ImageUtility::verifyColor($color)) {
         throw new ImageUtilityException('ImageGdUtility 錯誤!', '色碼錯誤!', '請確認色碼格式,目前只支援 字串HEX、陣列RGB 格式!');
     }
     if (!($degree % 360)) {
         return $this;
     }
     $temp = function_exists('imagecreatetruecolor') ? imagecreatetruecolor(1, 1) : imagecreate(1, 1);
     $newImage = imagerotate($this->image, 0 - $degree, imagecolorallocate($temp, $color[0], $color[1], $color[2]));
     return $this->_updateImage($newImage);
 }