N
N
nepster-web2014-05-03 01:49:10
Yii
nepster-web, 2014-05-03 01:49:10

Why does the yii2-image extension throw an error when using watermark?

I use Yii2, installed the yii2-image extension ( https://github.com/yurkinx/yii2-image)
Everything works except for 1 thing, this is watermark.
There is an example in the docs:

* $mark = Image::factory('upload/watermark.png');
* $image->watermark($mark, TRUE, TRUE);

// инициализирую основное изображение
$image=Yii::$app->image->load($dir.$model->image->name);
// инициализирую водных знак
$watermark = Yii::$app->image->load($dir.'wt.png');
// созраняю
$image->watermark($watermark)->save($dir.'___'.$filename);

The funny thing is that I'm catching an error:
Argument 1 passed to yii\image\drivers\Kohana_Image::watermark() must be an instance of yii\image\drivers\Image, instance of yii\image\drivers\Image_GD given, called in F:\OpenServerLast\domains\portf.ru\backend\protected\modules\admin\controllers\DefaultController.php on line 108 and defined

I paid attention to
public function watermark(Image $watermark, $offset_x = NULL, $offset_y = NULL, $opacity = 100)

And I pass the initialized $watermark and simply do not understand what kind of error it is. Please tell me what is the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-05-03
@nepster-web

What a miserable library, damn it.
This is clearly a port of the extension from 1.1, and thoughtless. They just wrapped everything with namespaces, but no one thought that the Image class, which is used in defining methods in the wrong namespace. Typical for Yii.
I recommend getting rid of this library and replacing it with normal solutions: intervention/image , gregwar/image ...

A
Alexander Zelenin, 2014-05-03
@zelenin

why not try the native image extension?

M
mclighter, 2014-09-22
@mclighter

Use https://github.com/yiisoft/yii2-imagine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question