#!
/usr/bin/env python
import os
from gimpfu import *
def batch_adjust_levels(image, drawable):
# Hardcoded input and output folders
input_folder = "C:\\folderL01" # Input folder path
output_folder = "C:\\folderL02" # Output folder path
# Ensure the output folder exists
if not [Link](output_folder):
[Link](output_folder)
# Iterate over all files in the input folder
for filename in [Link](input_folder):
# Construct the full file path
file_path = [Link](input_folder, filename)
# Check if the file is an image (you can add more extensions if needed)
if [Link]().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif', '.tiff')):
# Open the image
image = pdb.gimp_file_load(file_path, file_path)
# Get the active layer (drawable)
drawable = image.active_layer
# Start an undo group for the current image
pdb.gimp_image_undo_group_start(image)
# Adjust the levels: increase low input from 0 to 125
# Parameters: drawable, channel (0=value, 1=red, 2=green, 3=blue, 4=alpha), low-input, high-
input, gamma, low-output, high-output
pdb.gimp_levels(drawable, 0, 125, 255, 1.0, 0, 255) # Adjust value channel (0)
# End the undo group for the current image
pdb.gimp_image_undo_group_end(image)
# Construct the output file path
output_file_path = [Link](output_folder, filename)
# Save the image (use the appropriate file extension)
pdb.gimp_file_save(image, drawable, output_file_path, output_file_path)
# Clean up by closing the image
pdb.gimp_image_delete(image)
# Register the script in GIMP
register(
"python_fu_batch_adjust_levels", # Unique name for the script
"Batch Adjust Levels", # Short description
"Increase low input levels from 0 to 125 for a batch of images.", # Long description
"Your Name", "Your Name", "2023", # Author, copyright, date
"<Image>/File/Batch Adjust Levels", # Menu path
"", # No image required (batch processing)
[], # No input parameters
[], # No output parameters
batch_adjust_levels) # Function to call
main()