Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 983
Nikul Avatar asked Oct 17 '15 18:10

Nikul


1 Answers

could be a namespece access problem try add

 use yii\imagine;

to your code

like image 55
ScaisEdge Avatar answered Oct 18 '22 18:10

ScaisEdge