<?php
use Grafika\Grafika;
use Grafika\Color;
class OthImg
{
	public $editor = null;
	public $quality = 90;
	public function __construct($quality = 90)
	{	
		$this->quality = $quality;
		$this->editor = Grafika::createEditor();
	}

	/**将图片修改成指定大小
     * @param $src [string]  源图片文件名
     * @param $dest [string]  目标图片文件名,为空时则为$src
     * @param $angle [int]   旋转角度
     * @param $color [int]  颜色值
     * @return [bool]  成功: true, 失败 false
     */
    public function rotate($src, $dest, $angle, $color = null)
    {
		try {
			$this->editor->open($image, $src);
			if(!empty($color)) $color = new Color($color);
			$this->editor->rotate($image, $angle, $color);
			$this->editor->save($image, $dest, '', $this->quality);
			return LibFc::ReturnData(true, true);
		}catch (Exception $e) {
			return LibFc::ReturnData(false, 'rotate图片失败'.$e->getMessage());
		}
    }
}