Search code examples
pythonimagewebp

Is there a way to set image quality for webp images in python?


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


Solution

  • 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