1
0
mirror of https://github.com/brues-code/TwitchEmotes.git synced 2026-09-21 23:26:57 +00:00

Treat a zero GIF delay as 100ms

A GIF frame delay under 20ms means "as fast as possible", and browsers clamp
it to 100ms - the speed the emote actually plays at where people see it.
Summed literally, :Awkward: reported 76 frames lasting 0.1s and collapsed to
a single still. Any emote authored that way would have silently become a
static image.
This commit is contained in:
Brues
2026-09-04 03:14:21 -05:00
parent 0515d796af
commit 8d73824e9a
+5
View File
@@ -84,6 +84,11 @@ def load_frames(blob):
fitted.paste(scaled, ((cw - scaled.width) // 2, (ch - scaled.height) // 2))
frames.append(fitted)
durations.append(page.info.get('duration') or 0)
# A GIF delay under 20ms means "as fast as possible"; browsers clamp it to
# 100ms, so that is the speed the emote actually plays at where people see
# it. Taken literally, a sheet of zero-delay frames looks like a 0-second
# animation and collapses to one frame.
durations = [d if d >= 20 else 100 for d in durations]
return frames, durations, (cw, ch)