Skip to content

Instantly share code, notes, and snippets.

@pcgeek86
Last active February 11, 2024 22:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcgeek86/ae55fada48e6cf25516f2e064cfd0edb to your computer and use it in GitHub Desktop.
Save pcgeek86/ae55fada48e6cf25516f2e064cfd0edb to your computer and use it in GitHub Desktop.
Convert an animated .webp file to GIF with Python
#!/usr/bin/env python3
# Trevor Sullivan <trevor@trevorsullivan.net>
# https://trevorsullivan.net
# https://twitter.com/pcgeek86
# IMPORTANT: Install the webp Python package, using the following command:
# pip3 install --user webp
# Import the webp package
import webp
# Load a PIL image array from the specified .webp animation file
anim = webp.load_images('giphy.webp')
# Grab a reference to the first frame, and save the entire PIL image array as GIF with 70ms frames (14.286 FPS)
anim[0].save('output.gif', save_all=True, append_images=anim[0:], duration=70, loop=0)
@tzelalouzeir
Copy link

i

from PIL import Image

import requests
from io import BytesIO

#webp to gif convert
#webp link
url = 'https://cdn.7tv.app/emote/60a9cfe96daf811370b0b640/4x.webp'
#save image destination
destination = 'output1.gif'

response = requests.get(url)
img = Image.open(BytesIO(response.content))
img.save(destination,'gif',save_all=True)

founded from: https://groups.google.com/a/webmproject.org/g/webp-discuss/c/VcfpaZ0fJeM?pli=1

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