Gimp Plugin – fixed crop

This is a simple script to crop a plugin with fixed dimensions – I used it to crop out the window border from a VNC Client connected to an industrial touchscreen.

(script-fu-register
    "script-fu-crop"                    ;func name
    "Screenshot Crop"                   ;menu label
    "Crops an image to a fixed size"    ;description
    "Sandy Scott"                       ;author
    ""                                  ;copyright notice
    "January 11, 2015"                  ;date created
    ""               ;image type that the script works on
    SF-IMAGE    "Image"                 0
    SF-DRAWABLE "Drawable"              0
)
(script-fu-menu-register "script-fu-crop" "/Filters/Custom/")
(define (script-fu-crop image drawable)

    ; Prep
    (gimp-context-push)
    (gimp-image-undo-group-start image)
    
    ; Crop the image
    (gimp-image-crop image 800 480 8 30)
    
    ; Finishing Off
    (gimp-image-undo-group-end image)
    (gimp-context-pop)
    (gimp-displays-flush)
)

Save in the gimp scripts folder, something like C:\Users\JoeBloggs\.gimp-2.8\scripts\ on Windows, or /home/JoeBloggs/.gimp-2.8/scripts/ on Linux.

It will appear under Filters > Custom

Leave a Reply

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