0% found this document useful (0 votes)
5 views

Gimp script batch adjust level

This Python script for GIMP automates the process of adjusting the levels of images in a specified input folder by increasing the low input levels from 0 to 125. It checks for image files, processes each one, and saves the adjusted images to an output folder. The script is registered as a GIMP plugin for batch processing without requiring an image to be open.

Uploaded by

khurshid awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Gimp script batch adjust level

This Python script for GIMP automates the process of adjusting the levels of images in a specified input folder by increasing the low input levels from 0 to 125. It checks for image files, processes each one, and saves the adjusted images to an output folder. The script is registered as a GIMP plugin for batch processing without requiring an image to be open.

Uploaded by

khurshid awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#!

/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 os.path.exists(output_folder):

os.makedirs(output_folder)

# Iterate over all files in the input folder

for filename in os.listdir(input_folder):

# Construct the full file path

file_path = os.path.join(input_folder, filename)

# Check if the file is an image (you can add more extensions if needed)

if filename.lower().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 = os.path.join(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()

You might also like