02-16-2025, 10:35 PM
The API you can use is documented here: https://developer.gimp.org/api/3.0/libgimp/index.html
The resulting code is a lot less verbose than the PDB (or the examples auto-generated in the Python console). Of course the doc linked is C-oriented and the Python API is slightly more usable (instead of passing pointer to memory locations for results, you get the results in a returned tuple). For instance, your
is (using the documentation from here):
Going through the PDB/config raindance is still necessary when you call plugins, but even then there are ways to make it a lot shorter by delegating all the boilerplate code to a hgeneric function.
The resulting code is a lot less verbose than the PDB (or the examples auto-generated in the Python console). Of course the doc linked is C-oriented and the Python API is slightly more usable (instead of passing pointer to memory locations for results, you get the results in a returned tuple). For instance, your
Code:
def draw_brush(canvas, width, height):
procedure = Gimp.get_pdb().lookup_procedure('gimp-paintbrush-default')
config = procedure.create_config()
config.set_property('drawable', canvas)
config.set_property('strokes', [width/2, height/2])
result = procedure.run(config)
success = result.index(0)
is (using the documentation from here):
Code:
success=Gimp.paintbrush_default(canvas,[width/2,height/2])