为了账号安全,请及时绑定邮箱和手机立即绑定

有没有办法在 python 中为 webp 图像设置图像质量?

有没有办法在 python 中为 webp 图像设置图像质量?

皈依舞 2023-04-25 15:43:25
有没有办法在 python 中为 .webp 图像设置图像质量?例如,保存一张质量为 70% 的 webp 图片。
查看完整描述

1 回答

?
墨色风雨

TA贡献1853条经验 获得超6个赞

您可以使用 Pillow 模块执行此操作(但默认情况下它不随 Python 一起提供,请使用pip install pillow)


from PIL import Image               # import the PIL.Image module

img = Image.open("image.webp")      # open your image

img.save("image2.webp", quality=70) # save the image with the given quality


查看完整回答
反对 回复 2023-04-25
?
茅侃侃

TA贡献1842条经验 获得超21个赞

https://pypi.org/project/webp/ 这个包好像合适



查看完整回答
反对 回复 2023-04-25
  • 1 回答
  • 0 关注
  • 118 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信