I've scanned some book pages and imported them as layers to a single grey scale Gimp image. I need to do some identical Levels adjustments (primarily to correct white point) to each layer prior to exporting each layer as separate image using "Export layers" plugin.

Is there a way to adjust Levels info in bulk i.e. without having to do this adjustment per each layer separately?

For instance, if I'd wish to specify the white point for each layer to the value of 241, how would I manage to do that in one go or would I?

I am familiar with Layer Groups and available Layer options of G'MIC filter set, but to my knowledge these methods/plugins are not currently offering per layer color level batch operations. Do correct me if I'm wrong.

I typically do this with Imagemacik mogrify -level option via command line before importing the images as layers to Gimp, but on occasions I find I'd like to achieve this directly from within Gimp.

Specs: Windows 10 / Gimp 2.8.20

1 Answer 1


To level all the layers in batch mode:

  1. Copy this GIMP python-fu script:
#!/usr/bin/env python

from gimpfu import *

def level_all_layers(image, drawable, input_black, input_white, output_black, output_white):
    layer_number = len(image.layers)
    # Loop through each layer
    for i in range(layer_number):
        current_layer = image.layers[i]
        pdb.gimp_progress_update((i * 1.0) / layer_number)
        pdb.gimp_progress_set_text("Processing layer #" + str(i + 1) + "/" + str(layer_number) + "...")

        # Change the input levels to a certain value
        pdb.gimp_levels(current_layer, 0, input_black, input_white, 1, output_black, output_white)

    # Refresh the image to see the changes

# Define the parameters for the script
    "Level all layers",
    "Level all layers",
    "Fabrice TIERCELIN",
    "Fabrice TIERCELIN",
    "<Image>/Filters/Level all layers",
        (PF_SPINNER, "input_black", "Input black level (0-255)", 0, (0, 255, 1)),
        (PF_SPINNER, "input_white", "Input white level (0-255)", 255, (0, 255, 1)),
        (PF_SPINNER, "output_black", "Output black level (0-255)", 0, (0, 255, 1)),
        (PF_SPINNER, "output_white", "Output white level (0-255)", 255, (0, 255, 1))

# Main function
  1. Paste it into a text file
  2. Save it with a .py extension
  3. Put this file on your C:\Users\YourName\AppData\Roaming\GIMP\2.10\plug-ins folder (more information below if it doesn't work)
  4. Restart GIMP
  5. Open your file with the layers
  6. Go on FilterLevel all layers
  7. Choose the levels
  8. Launch the script
  9. Save your images

For systems other than Windows, look at the settings in GIMP:

  1. Click on Edit
  2. Click on Preferences
  3. Go on left pane, at bottom
  4. Click on Folders
  5. Click on Plug-ins
  6. Click on Add a new folder

Successfully tested on GIMP 2.10.36 on Windows 10.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.