GIMP Script-Fu Snippet Library

50+ copy-paste ready Script-Fu scripts for GIMP. Resize images, batch process files, adjust colors, add text, apply effects, and automate repetitive tasks — all from the Script-Fu Console.

GIMP 2.10+ GIMP 3.x Updated May 2026 50+ snippets
Press Ctrl+D (or ⌘D on Mac) to bookmark this page.

How to use these snippets

Open GIMP → FiltersScript-FuConsole. Paste any snippet and press Run. For batch scripts, update the file paths before running. Multi-line scripts work in the console — just paste the whole block.

What is Script-Fu?

Script-Fu is GIMP's built-in scripting language based on Scheme (a dialect of Lisp). It gives you full programmatic access to every GIMP function — the same operations you can do through menus and tools, but automated and repeatable.

Unlike plugins that require installation, Script-Fu runs directly in the Script-Fu Console (Filters → Script-Fu → Console) with no setup needed. It's perfect for one-off tasks, batch operations across hundreds of files, and building repeatable workflows.

Use these snippets as starting points, not black boxes. Read the description, update file paths and sizes, run on a duplicate image first, then save the version that works for your project. Script-Fu is especially useful when the same edit needs to happen many times, such as resizing an export folder, adding a watermark, normalizing layer names, or applying the same color adjustment to a set of images.

Task typeGood Script-Fu useUse GIMP manually when
Batch exportResize, convert, or watermark many files with the same settings.Each image needs different cropping or manual judgement.
Layer cleanupRename, merge, reorder, or apply masks consistently.The layer structure changes from file to file.
Color operationsRepeat levels, curves, desaturation, or palette prep.You need visual fine-tuning for each photo.
Template graphicsCreate repeated banners, labels, thumbnails, and text effects.The layout is one-off or heavily designed.
No Installation

Script-Fu is built into every GIMP install. Open the console and start scripting immediately.

Batch Processing

Loop over entire folders of images and apply the same operations to all of them at once.

Full API Access

Access thousands of GIMP procedures — everything from pixel-level edits to filter application.

Showing of 71 snippets

No snippets match your search. Try different keywords.

Image Ops

Resize image to 800×600

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/path/to/image.jpg" "image.jpg"))))
  (gimp-image-scale-full image 800 600 INTERPOLATION-LINEAR)
  (gimp-displays-flush)
  (gimp-image-clean-all image))

Loads an image from disk and scales it to exactly 800×600 using linear interpolation.

Image Ops

Flatten and export as JPEG

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/path/file.xcf" "file.xcf")))
       (drawable (car (gimp-image-flatten image))))
  (file-jpeg-save RUN-NONINTERACTIVE image drawable "/path/output.jpg" "output.jpg" 0.9 0 0 0 "" 0 1 0 2 0)
  (gimp-image-delete image))

Loads an XCF file, flattens all layers into one, then exports as JPEG at 90% quality.

Image Ops

Rotate image 90° clockwise

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-rotate image ROTATE-90))

Rotates the currently open image 90 degrees clockwise in-place.

Image Ops

Rotate image 180°

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-rotate image ROTATE-180))

Rotates the active image 180 degrees (flips both horizontally and vertically).

Image Ops

Crop to square from center

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (width (car (gimp-image-width image)))
       (height (car (gimp-image-height image)))
       (size (min width height))
       (x (/ (- width size) 2))
       (y (/ (- height size) 2)))
  (gimp-image-crop image size size x y))

Crops the image to the largest possible square, centered on the original image.

Image Ops

Get image dimensions

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (list (car (gimp-image-width image))
        (car (gimp-image-height image))))

Returns a list of (width height) for the currently open image.

Image Ops

Scale to max 1920px wide (keep ratio)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (width (car (gimp-image-width image)))
       (height (car (gimp-image-height image)))
       (max-w 1920))
  (when (> width max-w)
    (gimp-image-scale-full image max-w
      (round (* height (/ max-w width)))
      INTERPOLATION-LINEAR)))

Scales the image down to fit within 1920px width, maintaining the original aspect ratio. Does nothing if the image is already smaller.

Image Ops

Flip image horizontally

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-item-transform-flip-simple drawable ORIENTATION-HORIZONTAL TRUE 0))

Flips the active image horizontally (mirror left-right).

Image Ops

Convert to grayscale mode

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-convert-grayscale image))

Converts the image color mode to grayscale. This is different from desaturating — it changes the actual image mode.

Image Ops

Canvas size with layer resize

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-resize image 1200 900 0 0)
  (gimp-image-resize-to-layers image))

Enlarges the canvas to 1200×900 and resizes all layers to match the new canvas.

Layer Ops

Add new blank RGBA layer

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-layer-new image
                    (car (gimp-image-width image))
                    (car (gimp-image-height image))
                    RGBA-IMAGE "New Layer" 100 LAYER-MODE-NORMAL))))
  (gimp-image-insert-layer image layer 0 -1))

Creates a new transparent RGBA layer at the top of the layer stack at full image size.

Layer Ops

Duplicate active layer

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image)))
       (copy (car (gimp-layer-copy layer FALSE))))
  (gimp-image-insert-layer image copy 0 -1))

Duplicates the currently active layer and inserts the copy above it.

Layer Ops

Merge all visible layers

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))

Merges all visible layers into a single layer clipped to the image boundaries.

Layer Ops

Set layer opacity to 50%

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image))))
  (gimp-layer-set-opacity layer 50))

Sets the active layer opacity to 50%. Change the number (0–100) for other values.

Layer Ops

Set layer blend mode to Screen

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image))))
  (gimp-layer-set-mode layer LAYER-MODE-SCREEN))

Changes the active layer blend mode to Screen. Swap LAYER-MODE-SCREEN for any other mode constant.

Layer Ops

Flatten image (merge all layers)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-flatten image))

Completely flattens the image to a single non-transparent layer. Useful before exporting to JPEG.

Layer Ops

Delete active layer

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image))))
  (gimp-image-remove-layer image layer))

Removes the active layer from the image permanently.

Layer Ops

Resize layer to image canvas

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image))))
  (gimp-layer-resize-to-image-size layer))

Expands or contracts the active layer to match the full canvas size.

Layer Ops

List all layer names

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (for-each
    (lambda (layer)
      (gimp-message (car (gimp-item-get-name layer))))
    (vector->list (cadr (gimp-image-get-layers image)))))

Prints the names of all layers in the current image to the Script-Fu output.

Layer Ops

Set layer mode to Multiply

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (layer (car (gimp-image-get-active-drawable image))))
  (gimp-layer-set-mode layer LAYER-MODE-MULTIPLY))

Changes the active layer blend mode to Multiply — useful for darkening and compositing.

Color & Tone

Desaturate (keep RGB mode)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-drawable-desaturate drawable DESATURATE-LUMINOSITY))

Removes color from the active layer using luminosity weighting, keeping the image in RGB mode.

Color & Tone

Auto-stretch contrast

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-levels-stretch drawable))

Automatically stretches the tonal range of the layer to use the full 0–255 range.

Color & Tone

Adjust brightness and contrast

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-brightness-contrast drawable 20 30))

Increases brightness by 20 and contrast by 30. Use negative values to decrease.

Color & Tone

Boost saturation by 50

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-drawable-hue-saturation drawable HUE-RANGE-ALL 0 0 50 0))

Increases the saturation of all colors by 50. Adjust the last parameter (−100 to 100).

Color & Tone

Invert colors (negative)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-drawable-invert drawable FALSE))

Inverts all pixel values to create a negative image effect.

Color & Tone

Posterize to 4 levels

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-posterize drawable 4))

Reduces colors to 4 tonal levels per channel, creating a graphic poster effect.

Color & Tone

Set foreground color to red

GIMP 2.10+ / 3.x
(gimp-context-set-foreground '(255 0 0))

Sets the GIMP foreground color to pure red (255, 0, 0). Change the RGB values as needed.

Color & Tone

Fill layer with foreground color

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-edit-fill drawable FILL-FOREGROUND))

Fills the entire active layer with the current foreground color.

Color & Tone

Colorize layer (sepia-style)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-drawable-hue-saturation drawable HUE-RANGE-ALL 30 0 40 0)
  (gimp-drawable-desaturate drawable DESATURATE-LUMINOSITY)
  (gimp-drawable-hue-saturation drawable HUE-RANGE-ALL 30 0 20 0))

Applies a colorize effect at hue 30 (warm/sepia tone), saturation 40, lightness 0.

Color & Tone

Threshold (B&W cutoff)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-threshold drawable 127 255))

Converts the layer to pure black and white using a threshold of 127. Values below 127 become black, above become white.

Text

Add white text at position 10,10

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-text-fontname image -1 10 10
                         "Hello World" 0 TRUE 48 UNIT-PIXEL "Sans Bold"))))
  (gimp-text-layer-set-color text-layer '(255 255 255)))

Creates a new text layer with "Hello World" in 48px Sans Bold at position (10,10) in white.

Text

Resize text layer to image size

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-image-get-active-drawable image))))
  (gimp-layer-resize-to-image-size text-layer))

Expands the active (text) layer to fill the entire canvas. Useful before applying transforms.

Text

Add centered text watermark

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (width (car (gimp-image-width image)))
       (height (car (gimp-image-height image)))
       (text-layer (car (gimp-text-fontname image -1 0 0
                         "SAMPLE" 0 TRUE 72 UNIT-PIXEL "Sans Bold")))
       (text-w (car (gimp-drawable-width text-layer)))
       (text-h (car (gimp-drawable-height text-layer))))
  (gimp-layer-set-offsets text-layer
    (/ (- width text-w) 2)
    (/ (- height text-h) 2))
  (gimp-layer-set-opacity text-layer 40)
  (gimp-text-layer-set-color text-layer '(200 200 200)))

Adds a semi-transparent "SAMPLE" watermark centered on the image.

Text

Change text layer font size

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-image-get-active-drawable image))))
  (gimp-text-layer-set-font-size text-layer 64 UNIT-PIXEL))

Changes the font size of the active text layer to 64 pixels.

Text

Set text layer font

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-image-get-active-drawable image))))
  (gimp-text-layer-set-font text-layer "Arial Bold"))

Changes the font of the active text layer. Replace "Arial Bold" with any installed font name.

Text

Add bottom-right copyright text

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (width (car (gimp-image-width image)))
       (height (car (gimp-image-height image)))
       (text-layer (car (gimp-text-fontname image -1
                         (- width 180) (- height 36)
                         "© 2026 YourName" 0 TRUE 18 UNIT-PIXEL "Sans"))))
  (gimp-text-layer-set-color text-layer '(255 255 255))
  (gimp-layer-set-opacity text-layer 80))

Adds a small copyright notice 20px from the bottom-right corner of the image.

Text

Render text to raster layer

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-image-get-active-drawable image))))
  (gimp-floating-sel-to-layer (car (gimp-edit-copy text-layer))))

Flattens the text layer to a raster image, allowing pixel-level editing.

Text

Set text letter spacing

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (text-layer (car (gimp-image-get-active-drawable image))))
  (gimp-text-layer-set-letter-spacing text-layer 5.0))

Sets the letter spacing of the active text layer to 5.0 (kerning).

Filters

Gaussian blur radius 5

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-gauss RUN-NONINTERACTIVE image drawable 10 10 0))

Applies a Gaussian blur with radius 5 (10px kernel) to the active layer.

Filters

Unsharp mask (sharpen)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable 2.0 0.5 0))

Sharpens the image using unsharp mask. Parameters: radius 2.0, amount 0.5, threshold 0.

Filters

Add drop shadow

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (script-fu-drop-shadow image drawable 3 3 5 '(0 0 0) 70 TRUE))

Adds a black drop shadow 3px offset, 5px blur, 70% opacity to the active layer.

Filters

Emboss effect

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-emboss RUN-NONINTERACTIVE image drawable 315 45 7 TRUE))

Applies an emboss filter at 315° azimuth, 45° elevation, depth 7.

Filters

Motion blur (linear)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-mblur RUN-NONINTERACTIVE image drawable 0 20 0 0 0))

Applies linear motion blur at 0° angle with length 20 pixels.

Filters

Pixelize (mosaic effect)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-pixelize RUN-NONINTERACTIVE image drawable 10))

Creates a pixelized/mosaic effect with 10×10 pixel blocks.

Filters

Oilify (painting effect)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-oilify RUN-NONINTERACTIVE image drawable 8 1))

Applies the Oilify filter to give the image a painted/brush stroke appearance.

Filters

Add noise (HSV noise)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (plug-in-hsv-noise RUN-NONINTERACTIVE image drawable 5 25 3 25))

Adds HSV noise with dulness 5, saturation noise 25, hue noise 3, value noise 25.

File Ops

Batch resize all JPGs in folder

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/to/folder/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (width (car (gimp-image-width image)))
             (height (car (gimp-image-height image)))
             (new-w 800)
             (new-h (round (* height (/ new-w width)))))
        (gimp-image-scale-full image new-w new-h INTERPOLATION-LINEAR)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          filename filename 0.85 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Loads every .jpg in a folder, resizes to 800px wide (keeping aspect ratio), and saves back. Update /path/to/folder/ before running.

File Ops

Export active image as PNG

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (file-png-save RUN-NONINTERACTIVE image drawable
    "/path/output.png" "output.png" 0 9 1 1 1 1 1))

Exports the current image as a PNG file. Adjust the output path before running.

File Ops

Save as WebP (GIMP 2.10+)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (file-webp-save RUN-NONINTERACTIVE image drawable
    "/path/output.webp" "output.webp" 0 90 1 1 0 0 0 0 0))

Exports the current image as a WebP file at quality 90. Requires WebP plugin support.

File Ops

Convert all PNGs to JPEG in folder

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/*.png" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (outname (string-append (substring filename 0 (- (string-length filename) 4)) ".jpg")))
        (gimp-image-flatten image)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          outname outname 0.9 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Batch converts every PNG in a folder to JPEG at 90% quality. Update /path/*.png.

File Ops

Export as JPEG at quality 85

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-flatten image)
  (file-jpeg-save RUN-NONINTERACTIVE image
    (car (gimp-image-get-active-drawable image))
    "/path/output.jpg" "output.jpg" 0.85 0 0 0 "" 0 1 0 2 0))

Flattens and exports the active image as a JPEG at 85% quality. Good balance of size and quality.

File Ops

Print all open image names and sizes

GIMP 2.10+ / 3.x
(for-each
  (lambda (image)
    (gimp-message
      (string-append
        (car (gimp-image-get-filename image)) ": "
        (number->string (car (gimp-image-width image))) "x"
        (number->string (car (gimp-image-height image))))))
  (gimp-image-list))

Lists the filename and pixel dimensions of every currently open image to the Script-Fu output.

File Ops

Load image and get active drawable

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "/path/image.jpg" "image.jpg")))
       (drawable (car (gimp-image-get-active-drawable image))))
  ; ... do operations on image and drawable ...
  (gimp-image-delete image))

Loads an image file from disk and gets a reference to its active drawable layer — the standard setup for scripted edits.

File Ops

Save XCF (native GIMP format)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-xcf-save 0 image (car (gimp-image-get-active-drawable image))
    "/path/output.xcf" "output.xcf"))

Saves the current image in GIMP native XCF format, preserving all layers and metadata.

Selection

Select all and fill with foreground

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-selection-all image)
  (gimp-edit-fill drawable FILL-FOREGROUND))

Selects the entire canvas and fills it with the current foreground color.

Selection

Feather selection by 10px

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-selection-feather image 10))

Softens the edges of the current selection by feathering 10 pixels. Useful for smooth compositing.

Selection

Grow selection by 5px

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-selection-grow image 5))

Expands the current selection outward by 5 pixels in all directions.

Selection

Shrink selection by 5px

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-selection-shrink image 5))

Shrinks the current selection inward by 5 pixels — useful for removing halos around cut-outs.

Selection

Select by color (threshold 30)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list)))))
       (drawable (car (gimp-image-get-active-drawable image))))
  (gimp-by-color-select drawable '(255 255 255) 30 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE))

Selects all pixels at point (100, 100) that match within a tolerance of 30. Great for removing solid-color backgrounds.

Selection

Invert selection

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-selection-invert image))

Inverts the current selection — selected areas become unselected and vice versa.

Selection

Remove selection (deselect all)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-selection-none image))

Removes/clears the current selection so no area is selected.

Selection

Rectangular select region

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-select-rectangle image CHANNEL-OP-REPLACE 50 50 400 300))

Creates a rectangular selection at (50, 50) with width 400 and height 300.

Selection

Elliptical select (circle)

GIMP 2.10+ / 3.x
(let* ((image (car (gimp-display-get-image (car (gimp-display-list))))))
  (gimp-image-select-ellipse image CHANNEL-OP-REPLACE 200 200 200 200))

Creates an elliptical/circular selection. Here a 200×200 circle centered at (300, 300).

Automation

Watermark batch — add © text to all JPGs

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/input/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (width (car (gimp-image-width image)))
             (height (car (gimp-image-height image)))
             (text-layer (car (gimp-text-fontname image -1
                               (- width 200) (- height 40)
                               "© YourName" 0 TRUE 20 UNIT-PIXEL "Sans"))))
        (gimp-text-layer-set-color text-layer '(255 255 255))
        (gimp-image-flatten image)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          (string-append "/output/" (basename filename))
          (basename filename) 0.9 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Adds a white "© YourName" watermark to the bottom-right of every JPG in /input/ and saves to /output/. Update paths and name.

Automation

Batch desaturate all JPGs

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/to/folder/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-drawable image))))
        (gimp-drawable-desaturate drawable DESATURATE-LUMINOSITY)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          filename filename 0.9 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Converts every JPG in a folder to grayscale (desaturated) and saves back. Update /path/to/folder/.

Automation

Print all open image names and sizes

GIMP 2.10+ / 3.x
(for-each
  (lambda (image)
    (gimp-message
      (string-append
        (car (gimp-image-get-filename image)) ": "
        (number->string (car (gimp-image-width image))) "x"
        (number->string (car (gimp-image-height image))))))
  (gimp-image-list))

Lists the filename and dimensions of every open image. Useful for inspecting a batch before processing.

Automation

Batch add border to all PNGs

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/*.png" 1)))
       (border 10))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (w (car (gimp-image-width image)))
             (h (car (gimp-image-height image))))
        (gimp-image-resize image (+ w (* 2 border)) (+ h (* 2 border)) border border)
        (gimp-layer-flatten-image image)
        (gimp-image-flatten image)
        (file-png-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          filename filename 0 9 1 1 1 1 1)
        (gimp-image-delete image)))
    filelist))

Adds a 10px white border around every PNG in a folder by flattening on an enlarged white canvas.

Automation

Batch sharpen all JPGs

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-drawable image))))
        (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable 2.0 0.5 0)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          filename filename 0.9 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Applies unsharp mask sharpening to every JPG in a folder and saves back.

Automation

Batch rename and export as PNG

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/input/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (base (car (last (string-split filename "/"))))
             (outname (string-append "/output/"
                        (substring base 0 (- (string-length base) 4)) ".png")))
        (file-png-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          outname outname 0 9 1 1 1 1 1)
        (gimp-image-delete image)))
    filelist))

Loads all JPGs from /input/, converts and saves as PNG to /output/ with the same base filename.

Automation

Batch auto-levels (stretch contrast)

GIMP 2.10+ / 3.x
(let* ((filelist (cadr (file-glob "/path/*.jpg" 1))))
  (for-each
    (lambda (filename)
      (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
             (drawable (car (gimp-image-get-active-drawable image))))
        (gimp-levels-stretch drawable)
        (file-jpeg-save RUN-NONINTERACTIVE image
          (car (gimp-image-get-active-drawable image))
          filename filename 0.9 0 0 0 "" 0 1 0 2 0)
        (gimp-image-delete image)))
    filelist))

Applies automatic levels stretching to every JPG in a folder, improving exposure, and saves.

Automation

Count open images

GIMP 2.10+ / 3.x
(gimp-message
  (string-append "Open images: "
    (number->string (length (gimp-image-list)))))

Returns the number of images currently open in GIMP. Useful at the start of batch scripts.

Script-Fu Resources