I'm using https://github.com/php-imagine/Imagine (as use Imagine\Imagick\Imagine) to handle my images. I'm applying a transparent (alpha-channel) PNG image as watermark, following the docs here https://imagine.readthedocs.io/en/stable/usage/introduction.html#image-watermarking :
$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);
It works, but I'd like to reduce the opacity of the watermark, so it's less in-your-face.
I tried to search the docs via https://imagine.readthedocs.io/en/stable/search.html , but it doesn't seem to work.
Looking at the code, it appears that the
paste()method has an alpha argument built right into it:Since the argument is optional, and you're not overriding in your example, you're getting the default value of 100. To override, just explicitly provide a value less than 100 for the third parameter:
Note if you use a modern IDE, you'll get autocompletion on method arguments, and this sort of feature will become trivially easy to discover: