Search code examples
gimppython-fu

Functions for the Following GIMP Functionality


I'm making my first foray into GIMP scripting (hopefully in Python, but I'm open to Scheme too). I know exactly the steps I want to take using the GIMP UI, and I'm trying to determine which, if any, of the steps can be executed from a script, since the documentation I found suggested that not all functionality can be accessed in this way. Looking at the documentation helped with some, but not all, of what I'm looking for, so I'm hoping for a pointer as to which of the following functionality I can access from Python, and what function I will need, since my googling as come up short.

  • new layer
  • new layer from visible
  • duplicate layer
  • changing mode to overlay/grain extract/grain merge
  • gaussian blur
  • merge layer down
  • desaturate (lightness)
  • adjust color curves
  • filling a transparent layer with the paper pattern
  • adjust opacity

Solution

    • Open the Python console (Filters>Python-fu>Console).
    • Hit the Browse... button
    • Enter what you look for in the top bar on the left (for instance "desaturate")
    • Select the call in the list below the search filter and see the doc on the right

    This includes any callable installed script/plugin (if the authors did their homework). "Apply" copies a call template in the Python console.

    You can do more in Python than in Scheme.

    The doc for the Python classes is here. The more frequent API calls have corresponding methods/attributes.

    If you are on Windows, some tricks to ease your debugging here.

    There is not always a direct mapping between UI actions and the API. Some UI actions may correspond to several API calls.

    In Gimp 2.10, the GEGL filters aren't callable from Python (at least via the regular Gimp API), unless they replace an existing 2.8 filter (like the Gaussian blur).