Search code examples
schemegimpscript-fu

How to make a rectangular selection on an image in gimp using script-fu/scheme


I try my hands on scripting with scheme in gimp, and started with something that should be easy: write a script that creates a selection on the upper half of the image.

Something like (set! sel (gimp-create-selection img)) and then work on that selection. But the above function does not exist, nor can I find functions to manipulate selections.

It looks like a selection is not an object type of its own but rather another channel of the image.

So how can I create and manipulate a selection on an image? (Via script, not using the rectangular selection tool.) Is there an overview of gimp data types somewhere?

I know common LISP, so scheme syntax is not the main problem.


Solution

  • (gimp-image-select-rectangle image operation x y width height)
    

    In general, go to Filters>Script-fu>Console, and hit the "Browse..." button. Everything is documented there. Use the filter bar (I used rect) to locate possible candidates.

    If you are into ancient computing systems, this functions used to be:

    (gimp-rect-select image x y width height operation feather feather-radius)
    

    (found the same way, marked "deprecated" in 2.8)