Python 3 Pillow Script to Build Advanced Image & Webp Converter in Terminal
42 views
Jun 3, 2025
Buy the full source code of application here:
View Video Transcript
0:00
uh hello guys welcome to this video so
0:02
in this video I will show you how to use
0:05
the pillow library inside Python to
0:07
build out a advanced image and webp
0:10
converter inside your terminal so there
0:13
is this open-source
0:15
module below the command is simple you
0:18
simply execute pip install
0:22
pipl you simply install this module this
0:25
is a image processing module inside
0:27
python it's very good module it provides
0:31
you with all the features so once you
0:32
install this simply create a app py file
0:35
so we already have this image present
0:38
inside the directory you will see it's a
0:40
jpg image file so now if I want to
0:42
convert this to PNG it's really simple
0:46
first of
0:47
all we import the pillow
0:52
library we save from pillow we need to
0:55
import the image and then we simply open
0:59
the
1:03
image
1:04
so you can
1:06
see we use image and it contains this
1:10
open function so we simply open this
1:13
image first of
1:16
all and then it also contains the show
1:20
function which will show the image but
1:22
in this case we need to
1:25
actually convert this image from one
1:27
format to another so for this purpose we
1:30
have the save function so here you can
1:33
convert this image to PNG and then you
1:36
specify the extension so this is PNG so
1:40
now what happens it converts this image
1:42
from JPG extension to
1:45
PNG it's really simple and if you
1:48
execute the script here you will see a
1:51
new file will be created which will be
1:54
1.png so really simple converter and now
1:59
it can even convert this file to webp
2:02
format so webp format works in the
2:05
browser so here you just need to
2:09
specify webp and then I think you can
2:13
even control the quality as well so
2:15
there is a third argument that you can
2:17
pass to the spillow fun library which is
2:19
quality so in this way you can compress
2:22
your images as well so let's suppose I
2:25
pass here
2:27
50 so now what it will do it will
2:30
convert this jpg image to webp but with
2:33
quality 50 so you will see it has
2:36
created this webp file but the size will
2:39
be little bit different as you can see
2:41
the quality that we set is 50
2:45
let me set it to 100 uh
2:50
10 so now this image will be little bit
2:53
blurry and uh it can it is compressed
2:57
here you will see the original size of
3:00
the image was 28 kilobyte now it has
3:03
been reduced to 4 kilobyte so in this
3:05
way you can even compress your files as
3:07
well compress your image files and
3:10
change the image file from one format to
3:12
another using the simple pillow library
3:15
three lines of code is there you open
3:17
the image then you use the save function
3:21
to convert image from one format to
3:23
another so let's suppose I have this
3:25
webp file we can even convert this
3:29
to PNG as well so very
3:36
simply again you run this you will see
3:39
your file will be created so you can
3:43
convert files from one format to another
3:46
using this all-in-one pillow library
3:48
inside Python so thank you very much for
3:51
watching this video uh please subscribe
3:53
this channel for more videos like this
3:55
and also check out my website
3:57
freemediattools.com
3:59
uh which contains thousands of tools
#Multimedia Software
#Software