# -*- coding:utf-8 -*- # @Author len # @Create 2023/11/15 16:22 from PIL import Image, ImageEnhance import os # Path to the directory containing images directory = r'D:\Waste\嵌入式\数据集\车型\new_jpg' # Loop through all the files in the directory for filename in os.listdir(directory): if filename.endswith('.png') or filename.endswith('.jpg'): # Check for image files img_path = os.path.join(directory, filename) with Image.open(img_path) as img: # Increase brightness enhancer = ImageEnhance.Brightness(img) brighter_img = enhancer.enhance(1.5) # Increase brightness by 50% # Save the brighter image brighter_img.save(os.path.join(directory, 'brighter_' + filename)) print("Brightness of all images has been increased.")