fix stoat gifs

This commit is contained in:
rambros 2026-03-21 16:22:39 +05:30
parent 2c7937a05b
commit 28a2f4d1d7

View file

@ -499,12 +499,14 @@ async def migrate_messages(
frames = [] frames = []
durations = [] durations = []
# Create a RGBA canvas for disposal handling # Create a RGBA canvas for disposal handling
canvas = Image.new('RGBA', img.size, (0,0,0,0))
for i in range(img.n_frames): for i in range(img.n_frames):
img.seek(i) img.seek(i)
frame = img.convert('RGBA') frame = img.convert('RGBA')
canvas.paste(frame, (0, 0), frame) # Use a fresh canvas for each frame to avoid ghosting/stacking
frames.append(canvas.convert('RGBA')) # For stickers, we want each GIF frame to be independent
current_frame = Image.new('RGBA', img.size, (0,0,0,0))
current_frame.paste(frame, (0, 0))
frames.append(current_frame)
durations.append(img.info.get('duration', 100)) durations.append(img.info.get('duration', 100))
frames[0].save( frames[0].save(
gif_buf, format='GIF', save_all=True, gif_buf, format='GIF', save_all=True,