Python

How to blur an image in python?

How to blur an image in python?, someone asked me to explain?

In this tutorial I will show you how to blur an image in python. 
To blur an Image:
You can use OpenCV LIbrary, which provides various image processing methods including blurring. 

Install the opencv-python Library:

pip install opencv-python

Example Program:

import cv2

try:
    image = cv2.imread('angelina.jpg')  

    blurred_image = cv2.GaussianBlur(image, (15, 15), 0)

    cv2.imshow('Original Image', image)
    cv2.imshow('Blurred Image', blurred_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

    output_path = 'blurred_image.jpg'
    cv2.imwrite(output_path, blurred_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

except Exception as e:
    print(f"An error occurred: {e}")

OUTPUT:

blur image in python

VIDEO GUIDE:

Post your comments / questions