To apply curves on all images:
- Copy this GIMP python-fu script:
#!/usr/bin/env python
from gimpfu import *
def curves_in_all_images(dummy_image, dummy_drawable, in_1, out_1, in_2, out_2, in_3, out_3, in_4, out_4, in_5, out_5):
pdb.gimp_context_push()
# Get the list of all opened images
images = gimp.image_list()
image_number = len(images)
# Loop through each image
for i in range(image_number):
current_image = images[i]
pdb.gimp_progress_update((i * 1.0) / image_number)
pdb.gimp_progress_set_text("Processing image #" + str(i + 1) + " over " + str(image_number) + "...")
# Remember the image type
mode = current_image.base_type
if mode != RGB:
pdb.gimp_convert_rgb(current_image)
current_drawable = current_image.active_layer
# Curve the layer
points = [in_1, out_1, in_2, out_2, in_3, out_3, in_4, out_4, in_5, out_5]
pdb.gimp_curves_spline(current_drawable, HISTOGRAM_VALUE, len(points), points)
#if mode == INDEXED:
#pdb.gimp_image_convert_indexed(current_image, NO_DITHER, MAKE_PALETTE, 256, FALSE, FALSE, '')
#elif mode == GRAY:
#pdb.gimp_image_convert_grayscale(current_image)
# Save the image file
filename = pdb.gimp_image_get_filename(current_image)
pdb.gimp_file_save(current_image, current_drawable, filename, '?')
# Refresh the image to see the changes
pdb.gimp_context_pop()
pdb.gimp_displays_flush()
Define the parameters for the script
register(
"python_fu_curves_in_all_images",
"Curves on all images",
"Curves on all images and save; identical values will be ignored",
"Fabrice TIERCELIN",
"Fabrice TIERCELIN",
"2024",
"<Image>/Filters/Colors/Curves on all images",
"*",
[
(PF_FLOAT, "in_1", "In 1", 0.0),
(PF_FLOAT, "out_1", "Out 1", 0.0),
(PF_FLOAT, "in_2", "In 2", 0.0),
(PF_FLOAT, "out_2", "Out 2", 0.0),
(PF_FLOAT, "in_3", "In 3", 0.0),
(PF_FLOAT, "out_3", "Out 3", 0.0),
(PF_FLOAT, "in_4", "In 4", 0.0),
(PF_FLOAT, "out_4", "Out 4", 0.0),
(PF_FLOAT, "in_5", "In 5", 255.0),
(PF_FLOAT, "out_5", "Out 5", 255.0),
],
[],
curves_in_all_images
)
Main function
main()
- Paste it into a text file
- Save it with a
.py extension
- Put this file on your
C:\Users\YourName\AppData\Roaming\GIMP\2.10\plug-ins folder (more information below if it doesn't work)
- Start GIMP
- Open all your image files by drag and drop
- Go on Filter → Colors → Curves on all images
- Fill as many points as you need between the 5 ones; leave those useless
- Launch the script → all the files are already saved with the curves applied
- Quit GIMP ignoring the prompts
For systems other than Windows, look at the settings in GIMP:
- Click on Edit
- Click on Preferences
- Go on left pane; at bottom
- Click on Folders
- Click on Plug-ins
- Click on Add a new folder
Successfully tested on GIMP 2.10.36 on Windows 10.
PS: If you need more points, you can easily edit the script. Then restart GIMP.
It works fine with just this individual line changed to match the title of the curve file. There is absolutely no reason for this title to have been changed, and the only possible result of changing it is breaking backwards compatibility.
– John Cunningham May 03 '20 at 14:27