类别';想象\Gd\Imagine';在yii2中未找到

类别';想象\Gd\Imagine';在yii2中未找到,yii2,yii2-advanced-app,Yii2,Yii2 Advanced App,我在作物图像模块工作,我需要上传图像的细节,所以我使用这个功能 $image = Image::getImagine()->open($path); $size = $image->getSize(); 当使用这个函数时,它给了我一个错误 Class 'Imagine\Gd\Imagine' not found case self::DRIVER_IMAGICK: if (class_exists('Imag

我在作物图像模块工作,我需要上传图像的细节,所以我使用这个功能

$image = Image::getImagine()->open($path);
$size = $image->getSize();
当使用这个函数时,它给了我一个错误

Class 'Imagine\Gd\Imagine' not found

                case self::DRIVER_IMAGICK:
                    if (class_exists('Imagick', false)) {
                        return new \Imagine\Imagick\Imagine();
                    }
                    break;
                case self::DRIVER_GD2:
                    if (function_exists('gd_info')) {
                        return new \Imagine\Gd\Imagine();
                    }
                    break;
                default:
                    throw new InvalidConfigException("Unknown driver: $driver");
            }
        }
        throw new InvalidConfigException("Your system does not support any of these drivers: " . implode(',', (array) static::$driver));
此错误来自it库文件

vendor\yiisoft\yii2\imagine\BaseImage.php
我如何解决这个问题?谁能给我推荐一下吗

还添加了名称空间

namespace yii\imagine;

use Yii;

use yii\imagine\Image\Box;
use yii\imagine\Image\Color;
use yii\imagine\Image\ImageInterface;
use yii\imagine\Image\ImagineInterface;
use yii\imagine\Image\ManipulatorInterface;
use yii\imagine\Image\Point;



use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\helpers\ArrayHelper;

这是库文件,我从未更改过它,我也做过composer更新,但它仍然给了我相同的错误

可能是名称空间访问问题 尝试添加

 use yii\imagine;

对于你的代码

你有这个
使用yii\imagine在哪里调用函数?@husnanaslam。。至于上面的评论。。您必须添加使用yii\imagine;在这里调用函数