Dup Goto 📝

Cookbook1

PT2/graphics/gimp/scripting/python 07-31 13:46:46
To Pop
41 lines, 102 words, 1056 chars Monday 2023-07-31 13:46:46

Be aware that the scripting API is changing with Gimp 3.0.

Gimp 2.10

See this tutorial page

Layers

Add White Layer To Top Of Image

#!/usr/bin/env python2

from gimpfu import *

layer_types = { "RGB": 0, "RGBA": 1, "GRAY": 2, "GRAYA": 3 }
layer_modes = {'LightenOnly': 36, 'DarkenOnly': 35, 'Normal': 28}
fill_modes = {'Foreground': 0, 'Background': 1 }

def JDA_NewLayerBG(img,drawable):
  layer = gimp.Layer(img,"white",img.width,img.height,drawable.type|1,100,layer_modes["Normal"])
  img.add_layer(layer)
  pdb.gimp_drawable_fill(layer,fill_modes["Background"])

register(
    "jda-new-layer-bg",
    "fluff",
    "bubble",
    "wibble",
    "flurp",
    "2023",
    "JDA New Layer BG",
    "RGB*, GRAY*",
    [
        (PF_IMAGE, "image",       "Input image", None),
        (PF_DRAWABLE, "drawable", "Input drawable", None)
    ],
    [],
    JDA_NewLayerBG,
    menu="<Image>/Filters/JDA",
    domain=("gimp20-python", gimp.locale_directory)
    )

main()