Gimp-Forum.net
Can python access gegl tools? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: Can python access gegl tools? (/Thread-Can-python-access-gegl-tools)



Can python access gegl tools? - PixLab - 11-10-2021

I'm no python... at all.
I would like to know if we can write something in python using the "Filters/Map/Recursive transform..." tool, if so what would it be like?
Any reference to this tool using python would be wonderful


RE: Can python access gegl tools? - rich2005 - 11-10-2021

You could start here: https://www.gimp-forum.net/Thread-Scripting-GEGL-operations
and here: http://gimpchat.com/viewtopic.php?f=9&t=18040&start=10
Mostly script-fu but there is some python at the end.

There will also be some code in here: https://www.gimpscripts.net/2021/10/mrq-actions-rpl.html


RE: Can python access gegl tools? - PixLab - 11-23-2021

(11-10-2021, 06:49 PM)rich2005 Wrote: You could start here: https://www.gimp-forum.net/Thread-Scripting-GEGL-operations
and here: http://gimpchat.com/viewtopic.php?f=9&t=18040&start=10
Mostly script-fu but there is some python at the end.

There will also be some code in here: https://www.gimpscripts.net/2021/10/mrq-actions-rpl.html

Sorry for late answer, I forgot that I did post here.

I am searching for something more or less like
Code:
pdb.gimp_layer_recursive_transform(img, layer, parameter 1, 2, 3, 4, 5, and so on)
But I might be completely wrong
anyway thanks a lot Rich


RE: Can python access gegl tools? - rich2005 - 11-23-2021

A couple of plugins that you can look at Wink

First the fu-python-high-pass.py  This is the type that you want. It registers in the database as gegl-high-pass with parameters. Too complicated for me to adapt to recursive-transform.

The second gegl-command.py is an example of slotting a gegl function into a plugin written for the purpose.

Find information about the recursive transform variables: https://gegl.org/operations/gegl-recursive-transform.html
You can  get some gegl settings if you export the saved values to a file. Looks like this:

Code:
https://gegl.org/operations/gegl-recursive-transform.html
# GIMP 'Recursive Transform' settings

(time 0)
(transform "matrix(0.99331105831873456,0,0,0,0.95348834991455078,0,4,0,1)")
(first-iteration 3)
(iterations 5)
(fade-color (color-rgba 0 0 0 0))
(fade-opacity 1)
(paste-below no)
(sampler-type linear)

# end of 'Recursive Transform' settings

...and rewritten as a string 

Code:
gegl_graph_string="recursive-transform transform='matrix(0.99331105831873456,0,0,0,0.95348834991455078,0,4,0,1)' first-iteration=3 iterations=5 fade-color=rgba(0.0,0.0,0.0,0.10)  fade-opacity=1 paste-below=1 sampler-type=linear"

and that goes into the gegl-command.py in line 53  The plugin registers in the tools menu. 

Apart from that, I do not know,best of luck Wink

Edit: Does not work in Windows , such is life, probably needs the Windows GEGL binary installing.

Silly-me, It does work, I was not using a transparent layer.


RE: Can python access gegl tools? - PixLab - 11-24-2021

(11-23-2021, 04:03 PM)rich2005 Wrote: A couple of plugins that you can look at Wink

First the fu-python-high-pass.py  This is the type that you want. It registers in the database as gegl-high-pass with parameters. Too complicated for me to adapt to recursive-transform.

The second gegl-command.py is an example of slotting a gegl function into a plugin written for the purpose.

Find information about the recursive transform variables: https://gegl.org/operations/gegl-recursive-transform.html
You can  get some gegl settings if you export the saved values to a file. Looks like this:

Code:
https://gegl.org/operations/gegl-recursive-transform.html
# GIMP 'Recursive Transform' settings

(time 0)
(transform "matrix(0.99331105831873456,0,0,0,0.95348834991455078,0,4,0,1)")
(first-iteration 3)
(iterations 5)
(fade-color (color-rgba 0 0 0 0))
(fade-opacity 1)
(paste-below no)
(sampler-type linear)

# end of 'Recursive Transform' settings

...and rewritten as a string 

Code:
gegl_graph_string="recursive-transform transform='matrix(0.99331105831873456,0,0,0,0.95348834991455078,0,4,0,1)' first-iteration=3 iterations=5 fade-color=rgba(0.0,0.0,0.0,0.10)  fade-opacity=1 paste-below=1 sampler-type=linear"

and that goes into the gegl-command.py in line 53  The plugin registers in the tools menu. 

Apart from that, I do not know,best of luck Wink

Edit: Does not work in Windows , such is life, probably needs the Windows GEGL binary installing.

Silly-me, It does work, I was not using a transparent layer.

Wow, invaluable link and examples!
Thank you so much Rich