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.
How to use these snippets
Open GIMP → Filters → Script-Fu → Console. 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 type | Good Script-Fu use | Use GIMP manually when |
|---|---|---|
| Batch export | Resize, convert, or watermark many files with the same settings. | Each image needs different cropping or manual judgement. |
| Layer cleanup | Rename, merge, reorder, or apply masks consistently. | The layer structure changes from file to file. |
| Color operations | Repeat levels, curves, desaturation, or palette prep. | You need visual fine-tuning for each photo. |
| Template graphics | Create repeated banners, labels, thumbnails, and text effects. | The layout is one-off or heavily designed. |
Script-Fu is built into every GIMP install. Open the console and start scripting immediately.
Loop over entire folders of images and apply the same operations to all of them at once.
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.
Resize image to 800×600
(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.
Flatten and export as JPEG
(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.
Rotate image 90° clockwise
(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.
Rotate image 180°
(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).
Crop to square from center
(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.
Get image dimensions
(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.
Scale to max 1920px wide (keep ratio)
(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.
Flip image horizontally
(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).
Convert to grayscale mode
(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.
Canvas size with layer resize
(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.
Add new blank RGBA layer
(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.
Duplicate active layer
(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.
Merge all visible layers
(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.
Set layer opacity to 50%
(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.
Set layer blend mode to Screen
(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.
Flatten image (merge all layers)
(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.
Delete active layer
(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.
Resize layer to image canvas
(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.
List all layer names
(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.
Set layer mode to Multiply
(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.
Desaturate (keep RGB mode)
(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.
Auto-stretch contrast
(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.
Adjust brightness and contrast
(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.
Boost saturation by 50
(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).
Invert colors (negative)
(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.
Posterize to 4 levels
(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.
Set foreground color to red
(gimp-context-set-foreground '(255 0 0))
Sets the GIMP foreground color to pure red (255, 0, 0). Change the RGB values as needed.
Fill layer with foreground color
(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.
Colorize layer (sepia-style)
(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.
Threshold (B&W cutoff)
(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.
Add white text at position 10,10
(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.
Resize text layer to image size
(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.
Add centered text watermark
(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.
Change text layer font size
(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.
Set text layer font
(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.
Add bottom-right copyright text
(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.
Render text to raster layer
(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.
Set text letter spacing
(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).
Gaussian blur radius 5
(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.
Unsharp mask (sharpen)
(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.
Add drop shadow
(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.
Emboss effect
(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.
Motion blur (linear)
(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.
Pixelize (mosaic effect)
(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.
Oilify (painting effect)
(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.
Add noise (HSV noise)
(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.
Batch resize all JPGs in folder
(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.
Export active image as PNG
(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.
Save as WebP (GIMP 2.10+)
(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.
Convert all PNGs to JPEG in folder
(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.
Export as JPEG at quality 85
(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.
Print all open image names and sizes
(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.
Load image and get active drawable
(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.
Save XCF (native GIMP format)
(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.
Select all and fill with foreground
(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.
Feather selection by 10px
(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.
Grow selection by 5px
(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.
Shrink selection by 5px
(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.
Select by color (threshold 30)
(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.
Invert selection
(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.
Remove selection (deselect all)
(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.
Rectangular select region
(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.
Elliptical select (circle)
(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).
Watermark batch — add © text to all JPGs
(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.
Batch desaturate all JPGs
(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/.
Print all open image names and sizes
(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.
Batch add border to all PNGs
(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.
Batch sharpen all JPGs
(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.
Batch rename and export as PNG
(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.
Batch auto-levels (stretch contrast)
(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.
Count open images
(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
GIMP's official Script-Fu API documentation and migration guide for GIMP 3.x.
Learn Script-Fu from scratch with our beginner-friendly scripting and automation guide.
Browse all GIMP procedures directly in GIMP: Help → Procedure Browser. Find function signatures and arguments.
Browse our full library of beginner to advanced GIMP tutorials at GIMP.cc.