-1

Is there a way to set image quality for .webp images in python? For instance, saving a webp image with 70% quality.

Hissaan Ali
  • 2,229
  • 4
  • 25
  • 51

2 Answers2

3

You can do this with the Pillow module (but it doesn't come with Python by default, use 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
Tonechas
  • 13,398
  • 16
  • 46
  • 80
rémi couturier
  • 425
  • 3
  • 11
0

https://pypi.org/project/webp/ This package seems to be suitable

Vishesh Mangla
  • 664
  • 9
  • 20