This Python script uses the Pillow
library to perform various image enhancements on images present in the specified folder. It applies a series of enhancements to each image and saves the edited images in a separate folder.
Before running the script, make sure you have the Pillow
library installed. You can install it using pip
:
pip install Pillow
- Create two folders in the same directory as the script:
imgs
andeditedImgs
. - Place the images you want to enhance in the
imgs
folder.
- Save the script in a Python file, e.g.,
image_enhancer.py
. - Place the images you want to enhance in the
imgs
folder. - Execute the script in your preferred Python environment.
- The script imports necessary functions from the
Pillow
library. - It sets the
path
variable to the path of the folder containing the unedited images (imgs
). - It sets the
pathOut
variable to the path of the folder where the edited images will be saved (editedImgs
). - The script iterates through all the files in the
imgs
folder usingos.listdir(path)
. - For each image, it performs the following image enhancements:
- Brightness Enhancement: Increases the brightness of the image by 20% using the
ImageEnhance.Brightness
function. - Contrast Enhancement: Increases the contrast of the image by 50% using the
ImageEnhance.Contrast
function. - Color Saturation Enhancement: Increases the color saturation of the image by 20% using the
ImageEnhance.Color
function. - Additional Filters: Applies the sharpening filter using the
ImageFilter.SHARPEN
filter to further enhance image details. - Resizing (Optional): Resizes the edited image to half of its original size using the
resize()
method. This step is optional and can be adjusted based on your preference.
- Brightness Enhancement: Increases the brightness of the image by 20% using the
- The edited image is saved in the
editedImgs
folder with the filename format:<clean_name>_edited.jpg
, where<clean_name>
is the name of the original image without the file extension.
- The script applies various enhancements to improve the image quality and details.
- You can modify the enhancement values or add more enhancements based on your specific requirements. The Pillow documentation provides a comprehensive list of available enhancements and filters that you can explore and experiment with.
- Ensure that the
Pillow
library is correctly installed and compatible with your Python environment. - The script will overwrite existing edited images with the same name. Make sure to back up any important files before running the script.
Enjoy using this enhanced image editing script to improve your images with ease!