A basic Gimp script-fu

I’ve just been playing with Gimp, and getting to grips with the scripting system.

I’m sharing a very basic script – it only does two simple tasks:

  • Sets the image to Grayscale
  • Rotates 90 degrees counter-clockwise

It doesn’t need any extra parameters, so I thought I’d share it as a very simple example that you can adapt to your needs!

(script-fu-register
    "script-fu-test-script"                     ;func name
    "Test Script"                               ;menu label
    "Test script that does a few simple tasks"  ;description
    "Sandy Scott"                               ;author
    "Copyright 2013, Sandy Scott"               ;copyright notice
    "August 3, 2013"                            ;date created
    "*"                                         ;image type that the script works on
    SF-IMAGE       "Input image" 0
    SF-DRAWABLE    "Input drawable" 0 
            )
(script-fu-menu-register "script-fu-test-script" "/Filters/Test")

(define (script-fu-test-script image drawable)

    (let* ( )
        
        ; Prep
        (gimp-context-push)
        (gimp-image-undo-group-start image)
        
        ; Actual work here
        
        ; Convert to grayscale
        (gimp-image-convert-grayscale image)
        ;Rotate 90 CCW
        (gimp-image-rotate image ROTATE-270)
        
        ; Finishing Off
        (gimp-image-undo-group-end image)
        (gimp-context-pop)
        (gimp-displays-flush)
    )
)

Leave a Reply

Your email address will not be published. Required fields are marked *