#INTRODUCTION
This article I am gonna show you, How to convert all image file format into WebP format using PIL(Python Image Library) but first of all let me explain about what is WebP.
#WHAT IS WEBP?
WebP is an image format which is develop by Google, It is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.
#GETTING STARTED
##1. Library Setup
First of all , we have to install webp by using pip
pip install webp
then , we have to install pillow. If you have pillow install please reinstall it because it is not going to work. you can reinstall pillow by
pip uninstall Pillow
pip install Pillow
##2. Start Image Conversion
from PIL import Image
imagePath = "Your Image Path" #example ./test.jpg
outputPath = "Output Path" #example ./myWebPimage.webp
quality = "Number of quality you want" #example 100
im = Image.open(imagePath)
im.save(outputPath,'webp',quality = quality)
Yes , That's it. It is very easy. I hope you find it useful.