Answer the question
In order to leave comments, you need to log in
How to put a watermark on an image?
To upload images, I use this module https://github.com/CostaRico/yii2-images
How can I put a watermark on an image as simply as possible? Just a logo will be used as a watermark, I want to put it on the right in the corner.
Answer the question
In order to leave comments, you need to log in
in yii2 there is an imagine extension , here are the docks specifically for watermark: imagine.readthedocs.io/en/latest/usage/introductio...
$watermark = $imagine->open('/my/watermark.png');
$image = $imagine->open('/path/to/image.jpg');
$size = $image->getSize();
$wSize = $watermark->getSize();
$bottomRight = new Imagine\Image\Point($size->getWidth() - $wSize->getWidth(), $size->getHeight() - $wSize->getHeight());
$image->paste($watermark, $bottomRight);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question