ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

feature suggestion: per user watermark #245

Open andrisi opened 1 year ago

andrisi commented 1 year ago

To use watermarking even more efficiently - eg. discourage copying - it would be very useful to watermark images using personalized watermakrs per user. Could you add support to set the watermark file in the HTTP request? Like an image name from a predefined library? We could set that on server side based on authentication data. Thanks!

andrisi commented 1 year ago

...or to be even more flexible, a way for the server to get the image to be used on every use, that is on every time it wants to put it on an image, so different image on different tiles. It could be a command line app supplying them from a pool perhaps.

zabak commented 1 year ago

We have a use case where only some images should have a watermark so this would help us as well. We have iipsrv behind a proxy that checks for access rights and this proxy could set this parameter (and perhaps also WATERMARK_PROBABILITY and WATERMARK_OPACITY).

ruven commented 1 year ago

Could you add support to set the watermark file in the HTTP request?

You mean add support for a parameter like watermark= to each request? Won't your end-user be able to modify the URL and bypass the watermark in such a system?

If this parameter is not public, but is only added between the web server and iipsrv, then in fact it's possible to do something similar already. If you start several iipsrv instances, each with different WATERMARK images or probabilities you can configure your front-end web server to route internally the request either randomly to the different iipsrv instances or based on user or authentication data.

andrisi commented 1 year ago

@ruven yes a watermark parameter would be great, and it would be set by some middleware. The temp solution using several servers would not work as we will have tens of thousands of users... 😊 We need a "personal" watermark, like their email address on the images served.

ruven commented 1 year ago

Maybe using a HTTP header would be better in this case. Something like "X-Watermark-Image", "X-Watermark-Opacity" etc? Adding this feature, however, would require completely restructuring the watermarking code, so I'll look into this only after the release of version 1.2 of iipsrv.

andrisi commented 1 year ago

Thanks @ruven so how about an URL param for now? Otherwise a header is ok too, but really it doesn't matter. You can perhaps add a setting in the config file, to turn on this param, so it is not abused if not handled by a miffleware. Or you mean addig any kind of option is hard now? It's (from an outsider's point of view) pushing the URL param to the watermark filename. Or you preload it and sort of set it in stone?

ruven commented 1 year ago

Or you preload it and sort of set it in stone?

Yes, for performance reasons, the current implementation loads the watermark at start-up. Also tiles are watermarked before any other processing is done and are stored in the tile cache - if you have user-defined watermarks, this would need to be changed.

Whether we use a header or URL param to let the server know doesn't make much difference to the final implementation.

andrisi commented 1 year ago

Ok, I get it now.

It's a consideration (efficiency) but as we (and perhaps others with similar use cases) have large number of images and lots users but not very high usage, caching and in general efficiency on this level is less important. There won't be many cache hits in this scenario, and a less than ideal performance - loading watermarks per request - is acceptable tradeoff for the security provided by unique watermarks.

Your software is an excellent component in anyway, as it is now, and if the funding arrives for our project eventually I'd be happy to chip in to the development.

zabak commented 1 year ago

The watermark image could be cached in memcached as well I guess.

ruven commented 1 year ago

The watermark image could be cached in memcached as well I guess.

Indeed. Currently memcached can be used to cache requests. If each user sees a different version of the tile, then it will no longer be possible to have a common cache for all users.

andrisi commented 1 year ago

My guess in our use case is that users - like within an hour or day - rarely ever request the same image tile as there are so many images. Also that loading and processing the actual tiles is the heavier operation, not loading a watermark file which is just a few hundred bytes. You could also store watermark-less tiles in the cache?

I see you have an analytics package for IIPSRV, so you probably have some real data too, I'm just guessing.