brianium / watermarkjs

:rice_scene: Watermarking for the browser
http://brianium.github.io/watermarkjs/
Other
1.73k stars 232 forks source link

Apply watermark as a tile: multiple consequtive watermarks #52

Open shershen08 opened 6 years ago

shershen08 commented 6 years ago

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 ?

shershen08 commented 6 years ago

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: d24b5fe4-408d-4c6c-abc6-1e43a16d45e3