在 yii2 中找不到类“Imagine\Gd\Imagine" [英] Class 'Imagine\Gd\Imagine' not found in yii2

查看:44
本文介绍了在 yii2 中找不到类“Imagine\Gd\Imagine"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理裁剪图像模块,我需要上传图像的详细信息,所以我正在使用此功能

I am working on crop image module, I need detail of uploaded image so i am using this function

$image = Image::getImagine()->open($path);
$size = $image->getSize();

使用此功能时,它给了我错误

While using this function it is giving me error

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));

这个错误来自它的库文件

This error comes from it library files

vendor\yiisoft\yii2\imagine\BaseImage.php

我该如何解决这个问题?有人可以推荐我吗?

How can i solve this issue ? Can anyone please suggest me ?

命名空间也被添加

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;

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

This is library files, i never changed it, i also did composer update, still it is giving me same error

推荐答案

可能是 namespece 访问问题尝试添加

could be a namespece access problem try add

 use yii\imagine;

到你的代码

这篇关于在 yii2 中找不到类“Imagine\Gd\Imagine"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆