5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python - JPG,PNG, JPEG to WebP Format

Last updated at Posted at 2018-06-13

#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.

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?