Extend $image with $image->overlay() or $image->watermark()

i am looking for a neat way to be able to use the integrated image objects to be able to put a watermark on images with integrated methods such as

$image->watermark()
$image->overlay()

i have seen that there is somewhat something described in about an additional library but i guess it’s not integrated into kirby as far as i know:

another abandoned thread from here: New Kirby Watermark Plugin unfortunatly only delivers a dead link.

in my case i would like to upload several hundred pictures at once some super efficient idea would be great.

right now, i am using pretty basic php code working to get it done, but i wonder if i can optimize the process because i feel the processing takes a lot of horse power… other than that i’d love to get some recommendations to optimize the process of watermarking + resizing many images at once.

I still have this watermark plugin on disk if your are interested.

that would be lovely.

i have taken a super quick look inside the package, and it’s creating based on text. while this is fine too i wonder if it’s performing better than using a transparent png file for watermarking.

I have no answer to your question, I just had this plugin on file and thought it might be a starting point (have never used it myself), guess you have to either try it out or try to find some information on the web, or maybe someone else on this forum knows more.

Simple example of using the SimpleImage class to create an image watermark:

<?php
$image = $page->image('table.jpg');
if($image) {
  $img = new abeautifulsite\SimpleImage($image->root());
  $img = $img->overlay(url('assets/images/watermark.png'), 'bottom right', .5, -10, -10);
  $img->save($page->root() . '/' . $image->name() . '-overlay.jpg');
}
?>
1 Like

thanks @texnixe that helps out better than the watermark plugin the other day.

as reference for other users - you can actually chain each function just as you can do with kirby

$img = new abeautifulsite\SimpleImage($image->root());
$img
    ->overlay(url('assets/images/watermark.png'), 'bottom right', .5, -10, -10)
    ->best_fit(1200, 1200)
    ->save($page->root() . '/' . $image->name() . '-overlay.jpg');

i have seen that simpleimage already features a version 3 - while kirby includes 2.4.0.
is there any chance that it’ll get updated as well by any chance?

Hello Carsten,
my collegue Methab has developped the watermark plugin for our own site. I think it is the one Texnixe pointed too. Unfortunately it has never gotten the documentation and the place to be found. It is in operation on our 2.x kirby system and we do plan to migrate to 3.x in the next months.
I am glad to help you with the updated version as soon as available.
Moritz

i am actually playing around with several solutions to see what performs best.

the plugin (probably) you mention is not flexible enough for me, depending on image size, and text, the text does not seem to wrap around within the image but rather gets cut - i found no way to automatically add some linebreaks there.

the method of having that as a plugin is good though.

for the time being i am most likely sticking to the solution as described here in this thread - this seems fairly flexible and simple (choice of image/text as well as some other things) and it’s also somewhat available within kirby already - thus syntax is very similar.

obviously i am happy to try if there is any new update there, who knows it might then suit me better.

ok, good to know if there are other, better options - we will not pursue our plugin then for kirby 3

Check out https://www.visualwatermark.com/. I search for quite a while for watermarking software online and am super happy with these guys. No Cloud.

the solution i posted above works good enough for me.

in my case i am processing like 10 gb of data to get watermarked. so my intial batch will go though some software and if there’s some picture to get added later it’ll be done by php as above.

a free method to batch watermark images is XnView.
with a few settings you can resize and watermark and even leave folder stucture intact.

I doubt changing software doesn’t increase speed by much.