M
M
Maxim Lagoysky2017-05-26 14:38:36
Yii
Maxim Lagoysky, 2017-05-26 14:38:36

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

1 answer(s)
M
Maxim Timofeev, 2017-05-26
@lagoy

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 question

Ask a Question

731 491 924 answers to any question