sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Is there a way to set the "effort" option when composing GIFs?

Open jahvi opened this issue 3 years ago • 3 comments

Question about an existing feature

What are you trying to achieve?

I'm trying to reduce the time my composing method call takes but I'm not sure how the effort can be lowered in this case.

When you searched for similar issues, what did you find that might be related?

This issue is similar but they're not using composite.

https://github.com/lovell/sharp/issues/3176

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

// A set of GIFs and JPEGs
const frames = [...];
const gif = await sharp(animatedGif, { animated: true })
   .composite(frames)
   .toBuffer();

Please provide sample image(s) that help explain this question

N/A

jahvi avatar Jul 11 '22 16:07 jahvi

Hi, did you see the effort option of gif()?

https://sharp.pixelplumbing.com/api-output#gif

lovell avatar Jul 11 '22 17:07 lovell

Yea but doing something like:

const gif = await sharp(animatedGif, { animated: true })
   .composite(frames)
   .gif({ effort: 1 })
   .toBuffer();

Didn't make a difference so want sure if I was doing it wrong

jahvi avatar Jul 11 '22 18:07 jahvi

If you're still having problems, perhaps you could create a standalone repo with all input images and minimal source code that allows someone else to reproduce.

lovell avatar Jul 27 '22 09:07 lovell

GIF re-encoding should be ~20% faster in the forthcoming sharp v0.31.0 as the input palette will be re-used.

I'll close this for now, but please feel free to re-open with an example repo that allows someone else to reproduce if you still require help.

lovell avatar Aug 21 '22 19:08 lovell