anibali / pywebp

Python bindings for WebP
MIT License
74 stars 24 forks source link

Allow user to specify animation loop count #66

Closed anibali closed 5 months ago

anibali commented 5 months ago

From an email:

I can't find a way to specify loop_count for WebpAnimEncoder. The following in Google libwebp seems to be undefined in pywebp:

290 // Animation parameters.
291 struct WebPMuxAnimParams {
292   uint32_t bgcolor;  // Background color of the canvas stored (in MSB order) as:
293                      // Bits 00 to 07: Alpha.
294                      // Bits 08 to 15: Red.
295                      // Bits 16 to 23: Green.
296                      // Bits 24 to 31: Blue.
297   int loop_count;    // Number of times to repeat the animation [0 = infinite].
298 };
    ...

433 // Global options.
434 struct WebPAnimEncoderOptions {
435   WebPMuxAnimParams anim_params;  // Animation parameters.
436   int minimize_size;    // If true, minimize the output size (slow). Implicitly
437                         // disables key-frame insertion.
438   int kmin;
439   int kmax;             // Minimum and maximum distance between consecutive key

See also: https://developers.google.com/speed/webp/docs/container-api#webpmuxsetanimationparams

anibali commented 5 months ago

Added in https://github.com/anibali/pywebp/commit/2525817d40bca21bfebfe233dd77efeae5ec30f0