Gimp 3 Creating solid noise in Python plugin

With the release of RC1 some of the plugins that I have been porting have broken because noise filters are no longer accesible through pdb. So I have tried to create equivalent filters as functions using Gegl. This is quite simple to try using Gegl Graph but my attempt to write the function does not work and I get an error message
Gimp-3.0: Gimp-Core-CRITICAL: gimp_drawable_merge_shadow_buffer: assertion ‘GEGL_IS_BUFFER (drawable->private->shadow)’ failed
The code for the function is

def Solid_Noise(self, drawable, xset, yset, detset, tileset, turbset):

    """Based on Gegl graph
    id=in
    gegl:noise-solid
    	x-size=12
    	y-size=4
    	detail= 8
    svg:src-over
	aux =[ ref=in ]  which works as expected"""

    drawwidth = drawable.get_width()
    drawheight = drawable.get_height()

    draw_buffer = drawable.get_buffer()
    draw_shad_buffer = drawable.get_shadow_buffer()

    graph = Gegl.Node()

    draw_in = graph.create_child("gegl:buffer-source")
    draw_in.set_property("buffer", draw_buffer)

    noise = graph.create_child("gegl:noise-solid")
    noise.set_property("x-size", xset)
    noise.set_property("y-size", yset)
    noise.set_property("detail", detset)
    noise.set_property("tileable", tileset)
    noise.set_property("turbulent", turbset)
    noise.set_property("seed", random.randint(1, 16384))
    noise.set_property("width", drawwidth)
    noise.set_property("height", drawheight)

    comp = graph.create_child("svg:src-over")

    output = graph.create_child("gegl:write-buffer")
    output.set_property("buffer", draw_shad_buffer)

    draw_in.connect("output", comp, "input")
    noise.connect("output", comp, "aux")
    comp.connect("output", output, "input")

    output.process()

    draw_shad_buffer.flush()
    drawable.merge_shadow(True)
    drawable.update(0, 0, drawwidth, drawheight)
    Gimp.displays_flush()

    return

I guess I am missing something but what I cannot see. Any ideas please!

I have now tried porting the plasma filter in the same way with virtually identical code except for the actual noise or plasma node, Certainly the node connections are identical. This works exactly as expected with no error messages.

1 Like

Would my solution help you?

Hi Nelo. Like you I have been trying to follow the hints in goat exercise to develop functions that encapsulate the Gegl code. I have managed this for a number of the old pdb procedures that are no longer available. Your code for the unsharp mask will be one I use for that function. For a given plugin I really want to create the equivalent of a chain of gegl operations but I have to start by doing them one at a time. I am baffled here because for one operation (plasma) the code works as expected and for a similar one (solid noise) it does not. Also the error message makes no sense, The code defines the shadow buffer as a buffer which the message seems to deny.

I have the same problem and error message when I have tried to port “cell noise” and also “checkerboard” in the same way. I notice that all of these are derived from gegl OperationPointRender so perhaps there is some additional code needed - but what?

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.