1

how to convert a gif image to webp in python, keeping it's animation.

from PIL import Image
im = Image.open('test.gif')
im.save('test.webp', 'webp', save_all=True)

get KeyError, is there any python solution?

zephor
  • 687
  • 5
  • 13

1 Answers1

1

I just skimmed through the documentation for PIL, which says clearly that webp format is supported. It however comes with a condition. The page states Only supported if the system webp library was built with webpmux support.

In order to continue, you will have to install the latest libwebp library for your corresponding OS. It is recommended to work with it provided you have Debian/Ubuntu OS. There are plenty of resources available on the net to help you.

You may have to reinstall PIL as well

Here is a related thread I came across GITHUB thread

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87