GIMP Version: 2.8.22
Operating System: Windows
GIMP Experience: Basic Level
List any relevant plug-ins or scripts:voronoiList any ERROR messages you received:none
Did someone ever try to use voronoi from inside a filter?
Yesterday I tried it.
As opposed to qbist (which is not callable non-interactively, as ofnuts confirmed to me), I do not get any error, simply it doesn't do anything.
Here my initial code (I tried to reproduce the list of parameters used interactivelky, which works fine):
#!/usr/bin/env python
from gimpfu import *
def EasyVoronoiMosaic (inImage, inDrawable, inSize) :
pdb.gimp_context_push
currFG = pdb.gimp_context_get_foreground()
currBG = pdb.gimp_context_get_background()
# -------------------------------------------------------------------------------------
newImage = pdb.gimp_image_new(inImage.width, inImage.height, RGB)
BG_Layer = pdb.gimp_layer_new_from_drawable (inDrawable,newImage)
BG_Layer.name = "Background Layer"
BG_Layer.mode = NORMAL_MODE
newImage.add_layer(BG_Layer, 0)
VORONOI_Layer = BG_Layer.copy()
VORONOI_Layer.name = "Voronoi Layer"
VORONOI_Layer.mode = MULTIPLY_MODE
newImage.add_layer(VORONOI_Layer, 0)
alpha=pdb.gimp_drawable_has_alpha(VORONOI_Layer)
if (alpha==False):
pdb.gimp_layer_add_alpha (VORONOI_Layer) # RGBA
pdb.plug_in_voronoi (newImage, VORONOI_Layer,
11, #seed
-1, #cell-type: -1 = random, 0=square
inSize, #avg cell size
0.15, #unused when cell-type = random
0.7, #unused when cell-type = random
True, #hori tileable
True, #vert tileable
0.0, #value rescale(log)
0.0, #value shift
1, #coloring method: 0=independent RGB 1=gradient
0.0, #unused when cell-type = random
0.0, #unused when cell-type = random
0.0, #random color weight
0.0, #radial distanmce weight
0.0, #segment distance weight
1.0, #border distance weight
0.0, #second nearest distance weight
0.0, #scalar product weight
True, #invert gradient
"Abstract 1",
)
pdb.gimp_drawable_update (VORONOI_Layer, 0, 0, VORONOI_Layer.width, VORONOI_Layer.height)
# --------------------------------------------------------------------------------------
# ...
# do your stuff
# ...
# ...
pdb.gimp_context_pop
pdb.gimp_context_set_foreground(currFG)
pdb.gimp_context_set_background(currBG)
pdb.gimp_display_new (newImage)
return
register(
"EasyVoronoiMosaic", "EasyVoronoiMosaic", "EasyVoronoiMosaic",
"DN", "Open source (BSD 3-clause license)", "2017",
"EasyVoronoiMosaic",
"RGB*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),
(PF_ADJUSTMENT, "size", "Size of the cell", 20, (10, 40, 1)),
],
[],
EasyVoronoiMosaic,
menu="<Image>/Diego/Ancillary"
)
main()
If I do the same steps interactively (i.e.: open an image, duplicate it, duplicate the layer, run voronoi with those parameters) I get a nice result.
Using this on-going filter with the embedded call I simply get the layer duplicated, no voronoi.
What's wrong?
Thanks
update (13 August) I wrote to the author.
He said to me that after 15 or so years he doesn't even remember what a Gimp plug-in does, so he cannot help me directly.
According to what he remembers the plug-in was intended to run also non-interactively.
Hence I update here my request:
- can anyone expert in C read the source (attached in a subsequent post here) and understand what inhibits the plug-in to run non-interactively with the current Gimp version?
As stated previously, my pseudo-filter attached here as example does not return any error, simply does nothing.
If the problem is found, the source could be recompiled...
Spes ultima dea !