watermarkjs
watermarkjs copied to clipboard
Apply watermark as a tile: multiple consequtive watermarks
trafficstars
Consider the use case if I need to cover all the space of the source image with watermark. So use watermark as a tile: an example of what I want to achieve - tiled watermark image
For now I see the solution only in combing multiple atPos from the docs calls, depending on the size
Something like this:
// getX, getY - functions
let intermediate;
let counter = 0
const nextStep = () => {
counter++;
if counter < NEEDED_AMOUNT {
applySingleWatermark(intermediate || '/img/my_source_image.png')
}
}
const applySingleWatermark = (source) => {
watermark([source, '/img/my_watermark.png'])
.image(watermark.image.atPos(getX, getY, 0.6)).
.then(data => {
intermediate= data
nextStep()
)
}
Is there a better way?
If not, do you see a value in creating such functionality and submitting an MR ?
Here's a demo implementation of tiling with current API if someone will need it - https://codepen.io/shershen08/pen/KGmwmg
What you'll get is smth like:
