有没有办法在 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
添加回答
举报
0/150
提交
取消