Welcome folks today in this blog post we will be looking at how to blur an image file
in python using pillow
library. All the full source code of the application is given below.
Get Started
In order to get started you need to install pillow
library inside your python project by executing the pip
command which is shown below
pip install pillow
After installing this library just create an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 |
from PIL import Image, ImageFilter #Open existing image OriImage = Image.open('2.jpg') OriImage.show() #Applying GaussianBlur filter gaussImage = OriImage.filter(ImageFilter.GaussianBlur(5)) gaussImage.show() #Save Gaussian Blur Image gaussImage.save('gaussian_blur.jpg') |
Here in this block of code we are importing the library pillow
and then loading the input image path so here you need to replace the path of the image. After this you just need to run the python
application by running the below command
python app.py
As you can see the image has become fully blur
and in this way you can do this in python