Answer the question
In order to leave comments, you need to log in
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);
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
public function watermark(Image $watermark, $offset_x = NULL, $offset_y = NULL, $opacity = 100)
Answer the question
In order to leave comments, you need to log in
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 ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question