It is currently Tue Jul 02, 2024 11:27 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Sat May 20, 2023 7:11 pm  (#11) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Here is a list of all numbers for all Gimp only blend modes so they can be called in GEGL.

In example

47 is the Grain Merge Blend mode.
grainmerge = gegl_node_new_child (gegl,
                              "operation", "gimp:layer-mode", "layer-mode", 47, "composite-mode", 0, NULL);


39 is HSL Color

hslcolorig = gegl_node_new_child (gegl,
                              "operation", "gimp:layer-mode", "layer-mode", 39, "composite-mode", 0, NULL);


60 is the Gimp Split Blend mode.
xor = gegl_node_new_child (gegl,
                                    "operation", "gimp:layer-mode", "layer-mode", 60,  "composite-mode", 0, "blend-space", 0, "composite-space", 0, NULL);



57 is the Color Erase Blend mode.

colorerase = gegl_node_new_child (gegl,
                                    "operation", "gimp:layer-mode", "layer-mode", 57,  "blend-space", 1, NULL);


Attachment:




These operations will not work outside of Gimp but they are very useful for plugin development.


62 is Gimp's replace blend mode that I failed to list. My list ends at 61. lol


Last edited by contrast_ on Fri Jun 30, 2023 10:07 pm, edited 1 time in total.

Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Jun 30, 2023 10:06 pm  (#12) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Attachment:
plugins1.pdf [343.64 KiB]
Downloaded 119 times


Attachment:
plugins2.pdf [703.87 KiB]
Downloaded 140 times


Attachment:
plugins3.pdf [675.59 KiB]
Downloaded 125 times


Liam's GEGL plugin development guide with extra notes that isn't included on the website, its still 95% similar to the website


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Jun 30, 2023 10:10 pm  (#13) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
PDF documenting the most common reasons why my plugins will break in the future. NOTE ONE OF THEM IS GIMP'S TEAM ADDING A NEW BLEND MODE. This is for future maintainers. I don't expect this to happen anytime soon near future.

Attachment:
for_future_maintainers.pdf [40.87 KiB]
Downloaded 125 times


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Sep 15, 2023 8:22 am  (#14) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Souless Tree already made two node chaining type GEGL plugins but doesn't plan to make anymore. ( I asked him)
https://github.com/soulless-tree/soulless-gegl

BarefootLiam made one that calls the Pango Markup language, this is not a node chaining type plugin like I make.
https://gitlab.com/barefootliam/gegl-pango-markup

I made over 50 GEGL plugins, all of them are based around node chaining, but now as 2023 is in its later parts I have to wonder if the entire year will end with no other third party GEGL devs? Hopefully by the end of the year Gimp 3 is released and someone else considers making a GEGL plugin. I've been begging for this to happen for a long time to no avail.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Sep 15, 2023 10:40 am  (#15) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
If I wanted to create a GEGL plugin, where would I find the current guide to setting-up the tools on Windows for compiling the plugin?

Kevin


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Sep 15, 2023 11:00 am  (#16) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Install this
https://www.msys2.org/

Use Windows 64 bit and install install GEGL, Meson and Ninja afterward
https://packages.msys2.org/search?q=gegl


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Fri Sep 15, 2023 12:19 pm  (#17) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
paynekj wrote:
If I wanted to create a GEGL plugin, where would I find the current guide to setting-up the tools on Windows for compiling the plugin?

Kevin


If you can compile one of my plugins on Windows with those listed mysys2 tools. You have everything you need to develop a new plugin. So that will be the confirmation test.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Sun Oct 01, 2023 1:14 pm  (#18) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
paynekj wrote:
If I wanted to create a GEGL plugin, where would I find the current guide to setting-up the tools on Windows for compiling the plugin?

Kevin


I just repeated this process today because my virtual box Windows 7 broke.

Install MySys2

Run the Application MSYS2 MINGW64

Run this command inside MINGW64
pacman --noconfirm -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-meson mingw-w64-x86_64-gegl

This will install EVERYTHING NEEDED

If something unknown happens, it will only allow to compile plugins in this folder.
C:\msys64\home\USERNAME

but in most cases it will compile anything system wide.
Then opening the build_linux.sh files in MySys2 will compile my plugins. If you can compile my plugins you can compile your own.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Sat Oct 28, 2023 5:38 pm  (#19) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
The entire development of a GEGL plugin was documented in this thread.
viewtopic.php?f=9&t=20579&start=0


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 7:49 am  (#20) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
It is almost 2024 and I am at the point where I am literally integrating AI in my GEGL plugins and others have yet to make a single GEGL plugin, and based on view counts of threads on Gimp Chat it seems people are far more interested in calling GEGL From python then chaining GEGL nodes inside GEGL composers like I do.

GEGL from python will do interesting things but I beg the community to make a GEGL plugin the way I do. Its hard to believe I am still the only one doing this.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 10:54 am  (#21) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4001
Location: Canada
I don't know too much details about actually writing a GEGL plugin but I think the main reason for interest is ease of use.
if GEGL plugin involves having to compile then I think that's why people are hesitant at least it is for me.
I am guessing it's written in C? If so if there's a way to make a plugin in C that accepts dynamic chains in some format that and expose that to Python Fu.
Then Python Fu can call that and it could chain it dynamically then I guess there would be way more interest.
I don't know just my take on it.

_________________
TinT


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 5:41 pm  (#22) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
trandoductin wrote:
I don't know too much details about actually writing a GEGL plugin but I think the main reason for interest is ease of use.
if GEGL plugin involves having to compile then I think that's why people are hesitant at least it is for me.
I am guessing it's written in C? If so if there's a way to make a plugin in C that accepts dynamic chains in some format that and expose that to Python Fu.
Then Python Fu can call that and it could chain it dynamically then I guess there would be way more interest.
I don't know just my take on it.


I showed a Gimp dev your message and he told me it is possible to pass python stuff to GEGL, but didn't explain how. Remember I make all my GEGL plugins not by "coding in C via knowing the math of pixels" but just chaining GEGL nodes and GEGL composers in a designated area I dub "the playground".

This is "the playground" template where GEGL nodes and GEGL composers are orchestrated. It involves no math or no advance programming skills.

#include "config.h"
#include <glib/gi18n-lib.h>

#ifdef GEGL_PROPERTIES



property_double (yourpropertyname, _("Name for GUI"), 0.0)
   description (_("description"))
   value_range (0.0, 20.0)
   ui_range    (0.24, 20.0)
   ui_gamma    (3.0)



#else

#define GEGL_OP_META
#define GEGL_OP_NAME     my_new_gegl_plugin
#define GEGL_OP_C_SOURCE my_new_gegl_plugin.c

#include "gegl-op.h"

static void attach (GeglOperation *operation)
{
  GeglNode *gegl = operation->node;
  GeglNode *input, *output;

  input    = gegl_node_get_input_proxy (gegl, "input");
  output   = gegl_node_get_output_proxy (gegl, "output");

  geglop = gegl_node_new_child (gegl,
                                  "operation", "gegl:nop",
                                  NULL);



  gegl_node_link_many (input, output, NULL);
  gegl_node_link_many (input,  NULL);

  gegl_node_connect_from (input, "aux", output, "output");

gegl_operation_meta_redirect (operation, "yourproperty", opname, "propertyname");


}

static void
gegl_op_class_init (GeglOpClass *klass)
{
  GeglOperationClass *operation_class;

  operation_class = GEGL_OPERATION_CLASS (klass);

  operation_class->attach = attach;

  gegl_operation_class_set_keys (operation_class,
    "name",        "namespace:newplugin",
    "title",       _("My New GEGL Plugin"),
    "categories",  "newplugin",
    "reference-hash", "newplugin6a238a5125700fc254001b2ac",
    "description", _("Template for GEGL Plugins"),
    NULL);
}

#endif


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 8:12 pm  (#23) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4001
Location: Canada
I asked GPT and it said that we can compile the GEGL plugin into an .so file and put that in the plug-in folder
and that once that's successful it's registered in the pdb.
Then python fu can call it.
It's the compiling something in c that is proper format that I am unsure about.
But if that's done. Then it's a matter how we want to design the communication from python fu to that registered pdb call.

_________________
TinT


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 8:45 pm  (#24) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
wow, the AI was correct on that. MySys2 is how you compile my plugins on Windows. I'm sorry they are much harder on Windows. On Linux they compile so much easier. Also it is likely chatCPT got that information directly from me and my post scattered throughout the internet.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 9:18 pm  (#25) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4001
Location: Canada
I asked ChatGPT about dynamic c code execution and it said that it's slightly slower due to overhead in having to compile the code at run time. but its advantage is it can be dynamic. That was what I aiming to get at. It mentioned LLVM (Low Level Virtual Machine).
What I really wanted was some way for me to just change code on the fly without having recompile.
So even if a C plugin can accept this dynamic code from python which is also C code then it'll be a good interface for playing more because then Python can be changed without having to recompile that C plugin ever again. But ChatGPT also mentioned about security risks exposed because python can pass bad intent code... well that was expected. But I mean python code can already do harm on its own since it's runs code on your computer. But if python can change what kind of C code it passes into this C plug-in then we have something that's sort of like C scripting since it can be changed without recompiling the C plugin...

Chat GPT Gave me all this just in case anyone wants to venture into compiling a C plug-in that executes dynamic code:
1. Install LLVM:
Ensure that you have LLVM installed on your system. The steps for installation depend on your operating system.

2. Write a C Program:
c
Copy code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <llvm-c/Core.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm-c/Target.h>

int main() {
// The C code to execute
const char* cCode = "int add(int a, int b) { return a + b; }";

// Initialize LLVM
LLVMInitializeNativeTarget();
LLVMInitializeNativeAsmPrinter();

// Create an LLVM module and JIT engine
LLVMModuleRef mod = LLVMModuleCreateWithName("dynamic_module");
LLVMExecutionEngineRef engine;

char *error = NULL;
if (LLVMCreateExecutionEngineForModule(&engine, mod, &error) != 0) {
fprintf(stderr, "Could not create execution engine: %s\n", error);
LLVMDisposeMessage(error);
exit(1);
}

// Generate a simple function with the provided C code
LLVMValueRef mainFunc = LLVMParseBitcode(mod, (const uint8_t *)cCode, strlen(cCode), NULL, NULL);

// Execute the function (if it exists)
if (mainFunc != NULL) {
LLVMGenericValueRef result = LLVMRunFunction(engine, mainFunc, 0, NULL);
printf("Result: %lld\n", LLVMGenericValueToInt(result, 0));
} else {
fprintf(stderr, "Failed to parse C code\n");
}

// Clean up LLVM resources
LLVMDisposeModule(mod);
LLVMDisposeExecutionEngine(engine);

return 0;
}
3. Compile and Run:
Compile the program and run it. Ensure that the LLVM libraries are linked during compilation.

bash
Copy code
gcc -o dynamic_execution dynamic_execution.c -lLLVM
./dynamic_execution
This example dynamically executes the C code int add(int a, int b) { return a + b; }. Note that this is a simple example, and you would need more sophisticated error handling and validation for real-world scenarios.

Keep in mind that dynamically executing arbitrary C code poses security risks, and it's crucial to validate and sanitize input thoroughly to prevent code injection attacks. Also, ensure that you have proper error handling in place for various stages of the dynamic code generation and execution process.

_________________
TinT


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Dec 12, 2023 10:42 pm  (#26) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Gimp nor GEGL can't read GEGL .c files. Only binaries are accessible. In the future I hope they can read .c files instead of binaries only, as that is the spirit of FOSS


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Tue Feb 06, 2024 6:10 pm  (#27) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4001
Location: Canada
But isn't .GEGL files in c and compired using C? so if you make it dynamic and just include dynamic code as specified then compile it then when it runs it reads the dynamic code? Not sure.

Update:
does C have eval function like python
ChatGPT
No, C does not have an eval function like Python.

In Python, eval() is a built-in function that takes a string and executes it as Python code. This can be very powerful but also potentially dangerous, especially if the input is not sanitized properly, as it allows arbitrary code execution.

C, being a compiled language, doesn't have such an eval function because it doesn't interpret strings as code at runtime like Python does. C code is compiled into machine code before execution, so there's no direct equivalent to eval in C.

However, C can achieve similar functionality using techniques like dynamic loading of shared libraries or embedding interpreters like Lua or Python into C programs. These techniques allow you to execute code dynamically at runtime, but they are more complex and less commonly used than eval in Python. Additionally, they come with their own set of security considerations.

_________________
TinT


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Wed Feb 07, 2024 12:03 pm  (#28) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
trandoductin wrote:
But isn't .GEGL files in c and compired using C? so if you make it dynamic and just include dynamic code as specified then compile it then when it runs it reads the dynamic code? Not sure.

Update:
does C have eval function like python
ChatGPT
No, C does not have an eval function like Python.

In Python, eval() is a built-in function that takes a string and executes it as Python code. This can be very powerful but also potentially dangerous, especially if the input is not sanitized properly, as it allows arbitrary code execution.

C, being a compiled language, doesn't have such an eval function because it doesn't interpret strings as code at runtime like Python does. C code is compiled into machine code before execution, so there's no direct equivalent to eval in C.

However, C can achieve similar functionality using techniques like dynamic loading of shared libraries or embedding interpreters like Lua or Python into C programs. These techniques allow you to execute code dynamically at runtime, but they are more complex and less commonly used than eval in Python. Additionally, they come with their own set of security considerations.


I don't think its possible because Gimp's core libraries for GEGL use binaries too to load native GEGL filters. I sent your message to a gimp dev to see what he says. I too hope in the future it is possible to run GEGL plugins through .c files instead of binaries, as that is more transparent and in the spirit of open source but right now in this part of history it is likely not possible.

In the mean time while we wait for the day that GEGL can read .c files, we should occupy more important things like studying GEGL node chaining in Gimp's GEGL graph and making very simple basic GEGL plugins based on the graphs we find.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Wed Feb 07, 2024 1:28 pm  (#29) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
trandoductin wrote:
But isn't .GEGL files in c and compired using C? so if you make it dynamic and just include dynamic code as specified then compile it then when it runs it reads the dynamic code? Not sure.

Update:
does C have eval function like python
ChatGPT
No, C does not have an eval function like Python.

In Python, eval() is a built-in function that takes a string and executes it as Python code. This can be very powerful but also potentially dangerous, especially if the input is not sanitized properly, as it allows arbitrary code execution.

C, being a compiled language, doesn't have such an eval function because it doesn't interpret strings as code at runtime like Python does. C code is compiled into machine code before execution, so there's no direct equivalent to eval in C.

However, C can achieve similar functionality using techniques like dynamic loading of shared libraries or embedding interpreters like Lua or Python into C programs. These techniques allow you to execute code dynamically at runtime, but they are more complex and less commonly used than eval in Python. Additionally, they come with their own set of security considerations.


said Gimp dev responded

C files do indeed need to be compiled, and a compiler is a major piece of code. There are C interpreters, but they run very slowly (probably between 10 and a thousand times more slowly than compiled C for image processing) and aren't really designed for this sort of use.

GEGL plug-ins are indeed shared libraries (.so files, or .dll) that are loaded dynamically.


So yeah... it looks like it could be done but it would be 10 to 10000 times slower. I don't even know how to do it btw.


Top
 Post subject: Re: GEGL Plugin development guide from a Associate Gimp Developer
PostPosted: Sun Feb 11, 2024 12:10 pm  (#30) 
Online
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
Last week I made a new discovery on making GEGL plugins, and apparently someone from GNOME knew this trick back in 2013. Despite any public documentation of it.

I looked at the source code of GEGL's Gaussian Blur filter, something I had done long before.
During my previous look at gegl:gaussian-blur 's code I knew it was based on two gegl:gblur-1d being set horizontal and vertical. The stuff about gaussian blur is irrelevant to my discovery.

However just a few weeks ago I realized the nodes in the .c file were only listed once instead of twice. I didn't know this was possible. So in my latest filter that applies on a layer mask. I took note of gaussian-blur's .c file and made it where the code in my new filter only list nodes once instead of twice.

Example of required GEGL nodes being listed once (new discovery)

#define GEGL_OP_META
#define GEGL_OP_NAME     quickmaskfilter
#define GEGL_OP_C_SOURCE quickmaskfilter.c

#include "gegl-op.h"

static void attach (GeglOperation *operation)
{
  GeglNode *gegl = operation->node;

  GeglNode *input  = gegl_node_get_input_proxy (gegl, "input");
  GeglNode *output = gegl_node_get_output_proxy (gegl, "output");


   GeglNode *spread   = gegl_node_new_child (gegl,
                                  "operation", "gegl:noise-spread",  NULL);

    GeglNode *blur      = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);

    GeglNode *median     = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);

    GeglNode *median2     = gegl_node_new_child (gegl, "operation", "gegl:median-blur",  NULL);

    GeglNode *invertmask     = gegl_node_new_child (gegl, "operation", "gegl:component-extract",  NULL);
                                                                               
    GeglNode *increaseopacity     = gegl_node_new_child (gegl, "operation", "gegl:levels", NULL);
                           
  gegl_node_link_many (input, spread, median, blur, median2, invertmask, increaseopacity,   output, NULL);


Example of GEGL nodes being listed twice. (The way I've been doing things)

#define GEGL_OP_META
#define GEGL_OP_NAME     quickmaskfilter
#define GEGL_OP_C_SOURCE quickmaskfilter.c

#include "gegl-op.h"

static void attach (GeglOperation *operation)
{
  GeglNode *gegl = operation->node;
  GeglNode *input, *output, *spread, *blur, *median, *median2, *invertmask, *increaseopacity;

  input  = gegl_node_get_input_proxy (gegl, "input");
  output = gegl_node_get_output_proxy (gegl, "output");


   spread   = gegl_node_new_child (gegl,
                                  "operation", "gegl:noise-spread",  NULL);

    blur      = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);

    median     = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);

    median2     = gegl_node_new_child (gegl, "operation", "gegl:median-blur",  NULL);

    invertmask     = gegl_node_new_child (gegl, "operation", "gegl:component-extract",  NULL);
                                                                               
    increaseopacity     = gegl_node_new_child (gegl, "operation", "gegl:levels", NULL);
                           
  gegl_node_link_many (input, spread, median, blur, median2, invertmask, increaseopacity,   output, NULL);



What is the major difference?


   GeglNode *nodename

is put in front of every filter instead of a list like
  GeglNode *input, *output, *filter1, *filter2, *filter3;


This means it is EVEN EASIER to make a GEGL plugin.


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

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GEGL Textured Mosaic (in development)

3

No new posts Attachment(s) Baby's first GEGL plugin - a very basic GEGL plugin anyone can make.

9

No new posts THIRD PARTY GEGL FILTER GUIDE

14

No new posts Attachment(s) GEGL Starfield - Partially Inspired by David Wood's fireworks guide

16

No new posts Attachment(s) GEGL Background on top (first public GEGL plugin of 2024)

0



* Login  



Powered by phpBB3 © phpBB Group