Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Mar 8, 2023

Helps #7015

Alternative to #6977. This uses round() instead of int() to better approximate the data, and has a test using one of our existing images.

Animated PNGs can have float durations

self.im_info["duration"] = float(delay_num) / float(delay_den) * 1000

but when WebP goes to save the duration, it expects an integer.
enc.add(None, timestamp, 0, 0, "", lossless, quality, 0)

Pillow/src/_webp.c

Lines 206 to 209 in cdf5fd4

"z#iiisifi",
(char **)&rgb,
&size,
&timestamp,

The WebP API itself also expects the duration to be an integer. See https://developers.google.com/speed/webp/docs/container-api#webpanimencoderadd

int WebPAnimEncoderAdd(
WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms,
const struct WebPConfig* config);

So this PR rounds the duration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants