Enhance Image Brightness with Pillow

  • Share this:

Code introduction


This function enhances the brightness of an image using the Pillow library, which utilizes the ImageEnhance module. Users can specify an enhancement factor, which determines how much the brightness of the image will be increased.


Technology Stack : Pillow

Code Type : Image processing

Code Difficulty : Intermediate


                
                    
from PIL import Image, ImageEnhance

def enhance_image_brightness(image_path, factor):
    """
    Enhance the brightness of an image using Pillow.

    :param image_path: The path to the image file.
    :param factor: The factor by which the brightness is enhanced.
    """
    with Image.open(image_path) as img:
        enhancer = ImageEnhance.Brightness(img)
        img_enhanced = enhancer.enhance(factor)
        img_enhanced.show()                
              
Tags: