Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Scripting GEGL functions

Fri Feb 21, 2020 10:29 am

Untitled.png
Untitled.png (24.6 KiB) Viewed 9872 times


Where you see the G in the menus it means that it's a GEGL function and as yet the developers have not implemented any way to call GEGL functions from within scripts.

To find the ID of a layer you would get the list of layer-ids and check each one to see if the layer name matches the name you want to find.

Kevin

PS. You are advised to use Python instead of Script-Fu, especially if you have any programming experience already, purely for ease of use.

Re: Questions about Script-Fu

Fri Feb 21, 2020 11:37 pm

Ya, it's a real pain that after so much time developers did not update pdb to access Gegl functions.
Practically all scripters write their filters as if Gimp were still at version 2.8

Re: Questions about Script-Fu

Sat Feb 22, 2020 2:39 am

Hi Diego.

There are many people interested in answering Your question:
https://www.gimpusers.com/forums/gimp-d ... -gimp-gegl
so after 3 lost years he may ask again if there are any plans to solve this problem? In the next few years?

ps. We write in the thread opened by the spammer (deleted) - it does not bother me but it can change the title and department

Re: Questions about Script-Fu

Sat Feb 22, 2020 4:08 am

Maybe some C expert could at least provide a temporary solution, having the same characteristics of the interface to G'mic:
- one single interface
- each filter being called by a string of parameters comma separated, the first of which being the name of the filter itself followed by all single parameters required by that specific filter

Re: Questions about Script-Fu

Sun Feb 23, 2020 4:31 pm

Apparently you also need to be a Python expert, see the comment by Massimo Valentini
https://gitlab.gnome.org/GNOME/gimp/issues/1686 but it does offer the hope that GEGL functions might actually be scriptable.

Re: Questions about Script-Fu

Mon Feb 24, 2020 12:20 am

I had a look into Massimo Valentini's code.
My impression - an impression of a very simple gimp python coder, not at all an expert - is that it looks like a c code "dressed" in python, hence "arabic" for me.
I think only Ofnuts can really understand it.

Re: Questions about Script-Fu

Mon Feb 24, 2020 7:37 am

It's not all that difficult, most of Massimo's code is loading and starting gegl and doesn't change.

To prove a point I did the same for the GEGL Unsharp-Mask, so you should be able to compare the two and see how little changes.

The tricky bit is finding the definitions of the parameters. I downloaded the current source code for GEGL and found the C code defining each of the operations (gegl-master/operations/common). In unsharp-mask.c there is the following:
Code:
property_double (std_dev, _("Radius"), 3.0)
    description(_("Expressed as standard deviation, in pixels"))
    value_range (0.0, 1500)
    ui_range    (0.0, 40.0)
    ui_gamma    (3.0)
    ui_meta     ("unit", "pixel-distance")

property_double (scale, _("Amount"), 0.5)
    description(_("Scaling factor for unsharp-mask, the strength of effect"))
    value_range (0.0, 300.0)
    ui_range    (0.0, 10.0)
    ui_gamma    (3.0)

property_double (threshold, _("Threshold"), 0.0)
    value_range (0.0, 1.0)
    ui_range    (0.0, 1.0)
    ui_gamma    (1.0)


So now I knew that there are three parameters and that they are floats.

Hope this helps

Kevin

Edit 2020.08.24: removed the example code as it's the wrong way to do it.

Re: Questions about Script-Fu

Mon Feb 24, 2020 8:23 am

Thanks Kevin.
Still I personally don't feel comfortable and I will not try to define my own interfaces to Gegl functions.
I wait to get either from the "official" (ill?) gimp the appropriate pdb. entries, or from people like you the unofficial temporary python interfaces.
Thanks again.

Re: Questions about Script-Fu

Mon Feb 24, 2020 8:39 am

Thanks Kevin for the good information.

It seems that after one-time "difficult" preparation in python, further use (eg in script-fu) is very easy.
It is worth changing the title of the thread (and You - unexpectedly became the author of the thread) for such important and interesting information.
Maybe other users will post here their adaptations of subsequent GEGL filters?

I would also prefer to wait for official arrangements but I have no patience anymore. :oops:

Re: Scripting GEGL functions

Mon Feb 24, 2020 9:10 am

I've changed the thread title, but I also think it also could be moved into the Scripts and Plugins section

Re: Scripting GEGL functions

Mon Feb 24, 2020 5:26 pm

@Wallace
Can You make this change?

Thank You in advance.

Re: Scripting GEGL functions

Tue Feb 25, 2020 1:57 am

paynekj wrote:I've changed the thread title, but I also think it also could be moved into the Scripts and Plugins section

:bigthup

Re: Scripting GEGL functions

Sat Aug 22, 2020 12:34 am

I noticed that the "desaturating" function in GEGL (Color to Gray) looks to have much more interesting results than the standard non-GEGL one.

Would be someone willing to write the "interface" (in python) so that it can be called from a python filter?
I think it would be very useful for filter writers...

Re: Scripting GEGL functions

Sat Aug 22, 2020 4:00 am

If you want to try and experiment for yourself take a look over here: https://www.gimp-forum.net/Thread-Scrip ... operations

Otherwise I'll try and get to this next week.

Kevin

Re: Scripting GEGL functions

Sat Aug 22, 2020 4:21 am

Thank Kevin.
Downloaded and had a look inside.
It creates an interface to 3 GEGL operations (waterpixel, slic, emboss), isn't it?
But I feel myself totally inadequate to add another one, like Color to Gray, to which I'm interested currently.
So I will wait for you having time next week to do it; that's a very generous offer. Thanks.

Re: Scripting GEGL functions

Sat Aug 22, 2020 5:18 am

I've obviously not explained myself very well over on GimpForums

There's a python script that provides a scriptable interface to GEGL and an example script-fu to show how to use the python created pdb function.

Just to show how to do it, the script-fu actions those three GEGL functions in one go.

To use the python, you will need to know how to make command/parameter lists in the Filters>>Generic>GEGL Graph filter

Re: Scripting GEGL functions

Sat Aug 22, 2020 5:32 am

...which is very complex.

But: does this mean that the one I pointed to (which is already a GEGL filter, Color to Gray) can't be subject to your same manipulation, being the 3 listed above GEGL function and not filters?
IIRC somewhere it's said that you need to look into the GEGL filter and indentify the needed parameters before creating properly the python interface.

Re: Scripting GEGL functions

Sat Aug 22, 2020 8:28 am

To be more precise:
I have installed "gegl" unsharp mark, both the python pdb interface and the example calling scheme.
What I hope it could be done next week is the "same" for the "gegl" Color to Gray.

Re: Scripting GEGL functions

Mon Aug 24, 2020 10:30 am

I'm not going to create a C2G specific script, so try this instead:
dinasset_gegl.zip
(1.45 KiB) Downloaded 285 times


It's the code you need and an example script that does three actions, C2G, Softglow and Wind that illustrate some ways to build the GEGL Graph pipeline. This way you can easily add more GEGL actions to whatever code you are writing.

I make no claims that it will work on anything but Windows 10.

Re: Scripting GEGL functions

Mon Aug 24, 2020 11:02 am

Thanks a lot, Kevin
Post a reply