在yii2中找不到“Imagine \ Gd \ Imagine”类

时间:2015-10-17 18:22:37

标签: 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('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));

此错误来自库文件

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;

这是库文件,我从来没有改变它,我也做了作曲家更新,但它仍然给我同样的错误

1 个答案:

答案 0 :(得分:3)

可能是一个名字访问问题 尝试添加

 use yii\imagine;

代码

相关问题