我下载了 Yii 的 EasyImage 扩展来裁剪图像,但是每当我想初始化图像时,就会出现这个致命错误:
Fatal error: Call to undefined method Image::factory() in C:\Users\Daniel\Documents\GitHub\askengine\protected\extensions\yii-easyimage\EasyImage.php on line 41
想不通为什么。
我的控制器:
Yii::import('ext.yii-easyimage.EasyImage');
$image = new EasyImage("avatar/".$fileName);
$image->crop($_POST['w'], $_POST['h'], $_POST['x1'], $_POST['y1']);
$image->save();
EasyImage 类 _construct():
public function __construct($file = null, $driver = null)
{
if ($file) {
return $this->_image = Image::factory($this->detectPath($file), $driver ? $driver : $this->driver);
}
}
和 Image.php :
public static function factory($file, $driver = NULL)
{
if ($driver === NULL) {
// Use the default driver
$driver = Image::$default_driver;
}
// Set the class name
$class = 'Image_' . $driver;
return new $class($file);
}
我尝试直接使用 Image.php 但以失败告终:
Fatal error: Call to undefined method Image::factory() in C:\Users\Daniel\Documents\GitHub\askengine\protected\controllers\ImageController.php on line 60