GIMP MCP Skill
Purpose: Automate 2D image manipulation using GIMP Script-Fu (Scheme) or Python-Fu.
Setup
Ensure GIMP 2.10 or 3.0 is installed and GIMP_PATH is set if needed.
Capabilities
- •Script-Fu (Scheme): Native GIMP scripting. Good for batch processing filters.
- •Python-Fu: Python interface (GIMP 2.10 uses Python 2, GIMP 3.0 uses Python 3/GObject).
Usage
The MCP server exposes run_gimp_script_fu(script_code: str) and run_gimp_python_expression(expr: str).
Example (Script-Fu): Simple Resize & Blur
scheme
(define (simple-blur-resize filename out-filename width)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
; Resize image keeping aspect ratio
(let* ((old-width (car (gimp-image-width image)))
(old-height (car (gimp-image-height image)))
(ratio (/ width old-width))
(new-height (* old-height ratio)))
(gimp-image-scale image width new-height))
; Apply Gaussian Blur (Radius 5.0)
(plug-in-gauss RUN-NONINTERACTIVE image drawable 5.0 5.0 0)
; Save as PNG
(file-png-save RUN-NONINTERACTIVE image drawable out-filename out-filename 0 9 0 0 0 0 0 0)
(gimp-image-delete image)
)
)
(simple-blur-resize "C:/path/input.png" "C:/path/output.png" 800)
Note on Script-Fu
- •Scheme syntax uses prefix notation
(function arg1 arg2). - •Always close opened images with
(gimp-image-delete image)to free memory in batch mode. - •Use
RUN-NONINTERACTIVEfor plugins to suppress dialogs.
Example (Python-Fu / GIMP 2.10)
python
# To be run via run_gimp_python_expression?
# Note: The MCP tool currently takes a single expression line or block.
# Ideally use efficient one-liners or call existing plugins.
pdb.gimp_message("Hello from Python-Fu!")
Warning: Python-Fu support is tricky due to version differences. Prefer Script-Fu for stability if Python environment is uncertain.