I have hundreds of images, of which I want to perform the following operations in Gimp:

  1. Scale it using Sinc (Lanczos3)

enter image description here

  1. Change the input levels to a certain value

enter image description here

  1. Save it

My question is how do I perform these tasks in batch operation? If Gimp is not capable of doing such task, is there any alternative software?

  • 2
    The GIMP batch processor (BIMP) is here
    – Billy Kerr
    Jul 11, 2017 at 11:22
  • More of a SuperUser (usage approach) or StackOverflow (programming approach) question, though. Jul 11, 2017 at 13:54

1 Answer 1


To do all of this:

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

from gimpfu import *

def scale_level_save(ignored1, ignored2, scale_x, scale_y, black, white):
    # 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]
        current_drawable = current_image.active_layer
        pdb.gimp_progress_update((i * 1.0) / image_number)
        pdb.gimp_progress_set_text("Processing image #" + str(i + 1) + "/" + str(image_number) + "...")

        # Save the image type
        mode = current_image.base_type

        if mode != RGB:

        # 1. Scale the image using Sinc (Lanczos3) interpolation
        # Get the original dimensions of the image
        orig_width, orig_height = current_image.width, current_image.height

        # Calculate width and height from the scaling factors
        new_width, new_height = current_image.width * scale_x, current_image.height * scale_y

        # Scale the image using the Sinc (Lanczos3) interpolation method
        pdb.gimp_image_scale_full(current_image, new_width, new_height, INTERPOLATION_LANCZOS)

        # Scale the drawable (layer) to match the image dimensions
        pdb.gimp_layer_scale(current_drawable, new_width, new_height, True)

        # Resize the image canvas if the new dimensions are larger than the original
        if scale_x > 1 or scale_y > 1:
            pdb.gimp_image_resize(current_image, new_width, new_height, 0, 0)

        # 2. Change the input levels to a certain value
        pdb.gimp_levels(current_image.active_layer, 0, black, white, 1, 0, 255)

        # Restore the image type
        if mode == INDEXED:
            pdb.gimp_image_convert_indexed(current_image, NO_DITHER, MAKE_PALETTE, 256, FALSE, FALSE, '')
        elif mode == GRAY:

        # 3. Save the file
        filename = pdb.gimp_image_get_filename(current_image)
        pdb.gimp_file_save(current_image, current_image.active_layer, filename, '?')

    # Refresh the image to see the changes

# Define the parameters for the script
    "Scale image using Sinc (Lanczos3) interpolation, level and save",
    "Scale the image with the Sinc (Lanczos3) interpolation method",
    "Fabrice TIERCELIN",
    "Fabrice TIERCELIN",
    "<Image>/Filters/Scale Level and Save",
        (PF_FLOAT, "scale_x", "Scale X:", 2),
        (PF_FLOAT, "scale_y", "Scale Y:", 2),
        (PF_SPINNER, "black", "Black level (0-255)", 0, (0, 255, 1)),
        (PF_SPINNER, "white", "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. Start GIMP
  5. Open all your image files by drag and drop
  6. Go on FilterScale Level and Save
  7. Choose your options
  8. Launch the script → all the files are already saved with the 3 operations
  9. Quit GIMP ignoring the prompts

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.