How To Get Blur Effect of Given Images Using OpenPyXL?

Method

img2=img.filter(ImageFilter.GaussianBlur)    #Apply Gaussian blur

#img2=img.filter(ImageFilter.BLUR)    #Apply normal blur

Sample Code

#Blur Effect

from openpyxl import Workbook
from openpyxl.drawing.image import Image as xlImage
from PIL import Image,ImageFilter

#Create a workbook
wb=Workbook()
#Get the active worksheet
ws=wb.active

# Open the original image file
img=Image.open('pic.jpg')
img2=img.filter(ImageFilter.GaussianBlur)    #Apply Gaussian blur
#img2=img.filter(ImageFilter.BLUR)    #Apply normal blur

# Save the blurred image as a temporary file
path='image.jpg'
img2.save(path)

# Add the image to the worksheet
img=xlImage(path)
ws.add_image(img, 'A1')

# Save the workbook
wb.save('image07.xlsx')

# Delete the temporary file
import os
os.remove(path)
Get Blur Effect of Given Images Using OpenPyXL

Leave a Reply

Your email address will not be published. Required fields are marked *