It is currently Thu Apr 18, 2024 11:26 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: Re: Scripting GEGL functions
PostPosted: Mon Feb 24, 2020 5:26 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
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: 13008
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 273 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 subject: Re: Scripting GEGL functions
PostPosted: Mon Aug 24, 2020 10:28 pm  (#21) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
Hi Kevin.

Great solutions. :tyspin
Do you have a working example when it comes to choosing a color?
I am doing something very wrong because a tip from Massimo Valentini
"color", gegl.gegl_color_new (b "# 700")
,
does not help.

_________________
Image

Slava
Ukraini!


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

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Started using the method kindly provided by Kevin for using GEGL.
Look here: viewtopic.php?f=11&t=18691&start=30
I like much more GEGL c2g !
Thanks again Kevin !

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Aug 25, 2020 2:22 am  (#23) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
to specify a color you can use rgb(r,g,b) or rgba(r,g,b,a):
Attachment:
Untitled.png
Untitled.png [ 86.44 KiB | Viewed 4889 times ]


I recommend reading the information in the GEGL Graph dialog:
Attachment:
Untitled1.png
Untitled1.png [ 38.27 KiB | Viewed 4884 times ]


Kevin


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sun Sep 13, 2020 3:02 pm  (#24) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
A very good solution is presented on the website:
Samj Créations
https://samjcreations.blogspot.com/2020 ... -tres.html

Image

If you want to use gegl_list_all (for me the slashes must be in the opposite direction) this is in the attachment.

@Kevin
Late thanks for the information provided


Attachments:
gegl_list_all.zip [1.5 KiB]
Downloaded 164 times

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Sun Sep 13, 2020 5:27 pm  (#25) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
First tests....
The interesting thing about a plugin is that for it to work, you don't have to enter all its parameters - just the ones you want to change - and the rest are accepted by default.

Image

Image

If You are interested in parameter names and their range, you can find them in * .c files (in the appendix they come from Gegl Version: 0.4.24 - gegl\operations common).


Attachments:
Gegl-operations-common.zip [315.09 KiB]
Downloaded 167 times

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Sep 15, 2020 12:15 pm  (#26) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
I adapted the plug (a bit) to my needs:
Ver.2 - add: 80 operations, open the result as a layer, Preset in Notepad (separate entry in the menu: Filters/GEGL command & preset ...) with a list of operations (and to save by pasting versions of interesting settings).

Image
Image

Since the gegl.exe executable (Windows) is available in portable versions of Gimp from Samj Creation, but not in the official version of gimp.org - it is also included.
Why there are two fields for custom operations - to compare how changing a specific parameter affects the result (and keep the previous setting).

ps. Samj writes "Gegl_command_line.py" will likely be replaced by a C filter after Python 2 is abandoned.


Attachments:
Mosaic + apply-lens.png
Mosaic + apply-lens.png [ 89.76 KiB | Viewed 4178 times ]
Gegl_command_line V.2.zip [324.61 KiB]
Downloaded 181 times

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Sep 15, 2020 12:33 pm  (#27) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Is this version callable from a main .py filter?
Does it return the result to the caller?
If yes, could you write a very small example as a guide?
Thanks!

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Sep 15, 2020 1:22 pm  (#28) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
Hi Diego.

Usage is simple: :yes
- open any RGB photo *;
- run the plugin from the menu: Filters / GEGL command line ...;
- select the type of operation (80 standard +2 non-standard=Custom);
- select ExportType (PNG or JPEG);
- select how to open image (as a new layers or a new image);
- new images processed by Gegl are saved in the bin folder (and overwritten with);
- when you run ( Filters / GEGL & preset.txt command...) a document will open with a list of all operations and a link where you can find additional ones informations;
- in this I also save interesting settings for Custom;
- the record can be pasted into the plugin Command line GEGL (in Custom-1 or Custom-2)
- 80 operation is run without aditional parameters with default values ​​(there are many more operations in the documentation - but require additional parameters).

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Sep 15, 2020 1:59 pm  (#29) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
What you detailed is how to use it ONLINE
(2.point "run the plugin from the menu: Filters / GEGL command line ...")

I would like to run one filter written by me and -when a gegl operation is required- write something like
.....
outlayer=pdb.python_fu_gegl_command_line (inImage, inlayer, cmd string)
...
then do whatever next I need using outlayer produced by the gegl command line

Is it possible?

_________________
"Where am I ?"


Top
 Post subject: Re: Scripting GEGL functions
PostPosted: Tue Sep 15, 2020 2:17 pm  (#30) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I answer to myself: YES !
#!/usr/bin/env python
from gimpfu import *
def TestGEGLsamj(inImage, inLayer):

    gimp.message ("Hello!")
   
    wrklayer=inLayer.copy()
    inImage.add_layer (wrklayer,0)
    pdb.python_fu_gegl_command_line (inImage, wrklayer, 2, "blabla", "blabla", 0, 0)    # 2= alien map
    outlayer = inImage.layers[0]
   
    gimp.message ("Done!")
    # ...... do what you like on outlayer
   
   
    return

register(
    "TestGEGLsamj",
    "TestGEGLsamj",
    "TestGEGLsamj.",
    "Diego",
    "Diego Nassetti ",
    "2020",
    "TestGEGLsamj",
    "RGB*",
    [
        (PF_IMAGE, "image", "Input image", None),
        (PF_DRAWABLE, "drawable", "Input drawable", None),
        ],
    [
        (PF_IMAGE, "outimage", "Output image", None),
        ],
    TestGEGLsamj,
    menu="<Image>/Diego/Test",
    )

main()


_________________
"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



* Login  



Powered by phpBB3 © phpBB Group