-
-
Save pcgeek86/ae55fada48e6cf25516f2e064cfd0edb to your computer and use it in GitHub Desktop.
#!/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) |
The two methods (webp and PIL) yield the same poor image quality, the colors are fewer, the colors feel 8 bit or so
`import webp
from PIL import Image
im = Image.open(r'C:\Users\silve\Downloads\25036996.webp')
im.info.pop('background', None)
im.save(r'C:\Users\silve\Downloads\test.gif', 'gif', save_all=True)
anim = webp.load_images(r'C:\Users\silve\Downloads\25036996.webp')
anim[0].save(r'C:\Users\silve\Downloads\test2.gif', save_all=True, append_images=anim[0:], duration=70, loop=0)`
Hi, ty for this script. But, after conver my gif is very speed up? How to increase speed?
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
I noticed my python is the 32 bit version, and the webptools executables are 64 bit, maybe that's why I can't install neither webp or webptools modules. I'll try to test this hypothesis with a virtual machine so I don't mess up something