我为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