Class 'Imagine\Gd\Imagine' not found in yii2

半世苍凉 提交于 2020-01-24 04:03:01

问题


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 is also added

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


回答1:


could be a namespece access problem try add

 use yii\imagine;

to your code



来源:https://stackoverflow.com/questions/33190053/class-imagine-gd-imagine-not-found-in-yii2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!