It is currently Wed Apr 24, 2024 7:24 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Scripting GEGL functions
PostPosted: Fri Feb 21, 2020 10:29 am  (#1) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Attachment:
Untitled.png
Untitled.png [ 24.6 KiB | Viewed 9318 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.


Last edited by paynekj on Mon Feb 24, 2020 8:51 am, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Fri Feb 21, 2020 11:37 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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

_________________
"Where am I ?"


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Sat Feb 22, 2020 2:39 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2246
Location: Poland
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

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Sat Feb 22, 2020 4:08 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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

_________________
"Where am I ?"


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Sun Feb 23, 2020 4:31 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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.


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Mon Feb 24, 2020 12:20 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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.

_________________
"Where am I ?"


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Mon Feb 24, 2020 7:37 am  (#7) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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:
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.


Last edited by paynekj on Mon Aug 24, 2020 3:44 am, edited 1 time in total.

Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Mon Feb 24, 2020 8:23 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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.

_________________
"Where am I ?"


Top
 Post subject: Re: Questions about Script-Fu
PostPosted: Mon Feb 24, 2020 8:39 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2246
Location: Poland
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:

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Mon Feb 24, 2020 9:10 am  (#10) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I've changed the thread title, but I also think it also could be moved into the Scripts and Plugins section


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Mon Feb 24, 2020 5:26 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2246
Location: Poland
@Wallace
Can You make this change?

Thank You in advance.

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Feb 25, 2020 1:57 am  (#12) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13016
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
paynekj wrote:
I've changed the thread title, but I also think it also could be moved into the Scripts and Plugins section

:bigthup

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 12:34 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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...

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 4:00 am  (#14) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 4:21 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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.

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 5:18 am  (#16) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 5:32 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
...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.

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sat Aug 22, 2020 8:28 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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.

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Mon Aug 24, 2020 10:30 am  (#19) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I'm not going to create a C2G specific script, so try this instead:
Attachment:
dinasset_gegl.zip [1.45 KiB]
Downloaded 274 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.


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Mon Aug 24, 2020 11:02 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks a lot, Kevin

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts I figured out how to hide useless UI functions in GEGL filters.

1

No new posts Eager to learn how to draw pixel functions in GIMP python

2

No new posts Attachment(s) GEGL "Glass over Text' is STAND ALONE BUT NOW PART OF GEGL EFFECTS

5

No new posts Attachment(s) GEGL Bevel (filter of its own but now ships with GEGL Effects)

32

No new posts Help! Script-fu gegl:gegl works on only some of my third party filters

5


cron

* Login  



Powered by phpBB3 © phpBB Group