【问题标题】:How to Convert WebP image to Gif with Python?如何使用 Python 将 WebP 图像转换为 Gif?
【发布时间】:2019-01-31 15:21:24
【问题描述】:

我已经试过了:

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

这给了我这个错误

TypeError: &: 'tuple' 和 'int' 的操作数类型不受支持

我的网站上有数百张 webp 图片,需要将它们转换为 gif,因为 Firefox 不支持它。 谢谢。

【问题讨论】:

标签: python python-imaging-library gif webp


【解决方案1】:

在保存之前将背景设置为无。

from PIL import Image
im = Image.open('this.webp')
im.info.pop('background', None)
im.save('that.gif', 'gif', save_all=True)

感谢:https://github.com/python-pillow/Pillow/issues/2949#issuecomment-419422861

【讨论】:

  • 是否可以提高生成的 gif 的质量?
  • @FeraruSilviuMarian 可能是的。您应该检查枕头包装的文档。
  • 做了几个小时都没有用
  • 保存的文件似乎使用了更少的颜色
  • @FeraruSilviuMarian 我现在不记得这个过程,但可能是因为默认选项。
猜你喜欢
  • 2017-09-10
  • 1970-01-01
  • 2019-11-24
  • 2019-11-18
  • 2020-06-27
  • 1970-01-01
  • 2013-11-20
  • 2021-09-18
  • 2020-09-24
相关资源
最近更新 更多