1

I'm trying to make a composition on an animated gif. The overlay appears only for a small instance. I suppose that's because it's being applied only on one frame/page.

So my question is, how do I apply the overlay to all the pages/frames in the gif with sharp? This is the code:

 let image = await sharp(req.file.buffer, { animated: true, pages: -1 });
    const metadata = await image.metadata();
    await image
      .composite([
        { input: logo, left: Math.floor(metadata.width * 0.1), top: Math.floor(metadata.height * 0.1) },
      ])
      .toFile(filepath);

Thanks in advance!

Progman
  • 16,827
  • 6
  • 33
  • 48
Red Vic
  • 115
  • 1
  • 7

1 Answers1

2

Same issue here, fixed by using tile and gravity.

.composite([
    { 
        input: logo, 
        tile: true, gravity: 'northwest'
    }
])
Dre
  • 29
  • 1