Closed Directory closed 4 years ago
Please supply test.gif
its this. https://lukeroberts.tv/blog/wp-content/uploads/2019/05/gif1.gif. just downloaded and renamed.
OK thanks, I'll take a look when I get a chance.
additionally i encountered the exact same error but different traceback when using the advanced api.
the traceback for save_images
is
Traceback (most recent call last):
File "D:\Desktop\test.py", line 29, in <module>
webp.save_images(pframes, 'test.webp', fps=24, lossless=True)
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 590, in save_images
return mimwrite(file_path, arrs, **kwargs, pilmode=imgs[0].mode)
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 494, in mimwrite
pics = [WebPPicture.from_numpy(arr, pilmode=pilmode) for arr in arrs]
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 494, in <listcomp>
pics = [WebPPicture.from_numpy(arr, pilmode=pilmode) for arr in arrs]
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 223, in from_numpy
raise WebPError('unsupported image mode: ' + pilmode)
webp.WebPError: unsupported image mode: P
however the traceback for the advanced api is
Traceback (most recent call last):
File "D:\Desktop\test.py", line 32, in <module>
pic = webp.WebPPicture.from_pil(img)
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 235, in from_pil
return WebPPicture.from_numpy(np.asarray(img), pilmode=img.mode)
File "D:\Program Files\Python38\lib\site-packages\webp\__init__.py", line 223, in from_numpy
raise WebPError('unsupported image mode: ' + pilmode)
webp.WebPError: unsupported image mode: P
im on windows 10 and py3.8. Ive encountered the same error on ubuntu server 20.04. ive also tested it on this gif https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif and the same error occurs on both systems.
If you want to try something out in the meantime, try converting the PIL images to RGB mode after you open them:
pframes.append(Image.open(f).convert('RGB'))
Use RGBA if you need transparency.
Oh wow that actually did work. Thanks. It should probably be specified in the documentation or internally automatically convert it but for my use this works. Thanks.
Automatic conversion added in dfea4995696ce7091ecc8b0cd9446d31211d1abd.
I have a simple gif. I split the gif into each frame in a list. Each frame being an image object opned ans saved as a png. The same error happens when saved as BMP however its slightly different for JPEG.