Brightness enhancement of an image in a worksheet.
Code:
#Brightness Enhancement
from openpyxl import Workbook
from openpyxl.drawing.image import Image as xlImage
from PIL import Image,ImageEnhance
#Create a workbook
wb=Workbook()
#Get the active worksheet
ws=wb.active
# Open the original image file
img=Image.open('pic.jpg')
#Apply brightness enhancement
bright=ImageEnhance.Brightness(img)
img2=bright.enhance(2)
# Save the enhanced 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('image13.xlsx')
# Delete the temporary file
import os
os.remove(path)
