Text as watermark in front-end

pwrobel - 1 month ago

I need to add text as watermark to every image in gallery on page. I display gallery through page types, so I need a twig solution. I didnt find it in docs. Intervention library has o text method but i cant use it in twig. Is there any simple way to do this?

edster - 1 month ago

Check the files documentation. My guess is the method hasn't been enabled by Ryan at all, which is why you can't use it in twig.

To get it fixed make an issue on GitHub.

ryanthompson - 1 month ago

Image plugin / class in Pyro wraps Intervention and that method should be allowed. Something like this I imagine:

{{ image('theme::img/my-image.jpg').insert(image_path('theme::another/image.jpg'), bottom-right, 10, 10)|raw }}


pwrobel - 1 month ago

Yup, there is no problem with insert image as watermark. Problem is that I need insert text as watermark. I tried to use {{ image('path').text(' my text).url() }} (intervention has text method) but it didnt work for me. I think insert method shouldn't work too in this case.

ryanthompson - 1 month ago

Aha! Good call - I've added it to the allowed methods: https://github.com/anomalylabs/streams-platform/commit/60393bc4f46a7c51cbd2ae675c08983f5aae3242

Let me know how this works!

pwrobel - 1 month ago

I tried that solution before, but it didnt work for me.

{% for photo in page.aups %}
        {{ image(photo).fit(900,1500).text('some text', 10, 10)|raw }}
{% endfor %}

I tried do it that way. Inserting images works perfectly but I cant find solution for that :(.

ryanthompson - 1 month ago

Bah looks like they're working but I need to map the closure options to an array of config for the plugin use:

See my pathetic example / output lol: https://image.prntscr.com/image/ead0d1e21f494f63a64f0ac0a03cb94c.png

That's at like 300% zoom

I'll get this knocked out and let you know.

pwrobel - 4 weeks ago

Ok, thanks for help Ryan!