Python Pillow – Blur Image

Pillow – Blur image

To blur an image using Pillow library, you can use Image.filter() function with ImageFilter.BLUR kernel filter.

Python Pillow - Blur Image

Steps to blur an image

Follow these steps to blur a given image.

  1. Import Image, and ImageFilter modules from Pillow library.
  2. Read input image using function.
  3. Call filter() function on the read Image object and pass ImageFilter.BLUR as argument to the function. The function returns blurred image as PIL.Image.Image object.
  4. Save the returned image to required location using function.

Syntax of filter() function

The syntax of filter() function from PIL.Image module is

filter_kernelA filter kernel that applies to the given image. To blur the image, you can use ImageFilter.BLUR filter kernel.


The function returns a PIL.Image.Image object.


1. Blur a given image

In the following example, we read an image test_image.jpg, blur this image using Image.filter() function, and save the blurred image as blurred_image.jpg.

Python Program

from PIL import Image, ImageFilter

# Open the image
image ="test_image.jpg")

# Blur the image
blurred_image = image.filter(ImageFilter.BLUR)

# Save the resulting image"blurred_image.jpg")

Original Image [test_image.jpg]

Python Pillow - Blur Image - Input

Resulting Image with BLUR effect [blurred_image.jpg]

Python Pillow - Blur Image - Output


In this Python Pillow Tutorial, we learned how to blur a given image using PIL.Image.filter() function, with the help of examples.

Related Tutorials

Code copied to clipboard successfully 👍