Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting GEGL operations
As someone eventually raised an issue about scripting GEGL: I took the code Massimo wrote and butchered it a bit to make it easier to create multiple PDB entries.

I would appreciate it if someone on Linux would try out my code to see if it works (as I only have Windows).

Suggestions on code improvements/re-writes welcome Smile

There are two files in the zip archive. The Python that does the work and the .scm that uses the new gegl operations, which registers scripts here


EDIT 2020.08.24: Removed attachment as it's the wrong way to do it.
kubuntu 18.04 / Gimp 2.10.18 (appimage)  (regular Gimp 2.10.14 the same)

I get error messages here:  This for waterpixels, the other two similar.

The gegl operation does work when applied manually. Looks like it is case sensitive Average / average

Tried adjusting your script-fu on that basis without success.

edit: using gimp 2.10.14  & gimp --verbose

Looks like the python plugin not working due to the Windows path "C:/....." Which would explain the error messages.

Querying plug-in: '/home/rich/gimp210/plugin-test/' [/color]
Traceback (most recent call last):
 File "/home/rich/gimp210/plugin-test/", line 6, in <modu
   sys.stderr = open('C:/temp/python-fu-output.txt','a')
IOError: [Errno 2] No such file or directory: 'C:/temp/python-fu-output.txt'
gimp: LibGimpBase-WARNING: gimp: gimp_wire_read(): error
Terminating plug-in: '/home/rich/gimp210/plugin-test/'

I've just spotted a thing that might break the python:

Try comenting out the lines at the top:
#import sys
#sys.stderr = open('C:/temp/python-fu-output.txt','a')
#sys.stdout=sys.stderr # So that they both go to the same file

As that's redirecting print and error messages to a file on my Windows machine that you don't have.
yes, I assumed that. disabled that now this

Querying plug-in: '/home/rich/gimp210/plugin-test/'
Traceback (most recent call last):
  File "/home/rich/gimp210/plugin-test/", line 20, in <module>
    gimp = load_library ('libgimp-2.0')
  File "/home/rich/gimp210/plugin-test/", line 17, in load_library
    return CDLL (library_name)
  File "/usr/lib/python2.7/ctypes/", line 366, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: cannot open shared object file: No such file or directory

looks like it should be
That's the thing I was most concerned about - would it open the correct library. Is it possible that the library will have different names on different Linux distributions?
I had a look in my PClinuxOS desktop, which is a bit different to this kubuntu notebook. Still the same although different folders (usr/lib vs. usr/lib64) is the name and is a symbolic link to the current version file)

Got your scripts working here, kubuntu 18.04 / gimp 2.10.14

The python plugin - line 1 and line 11

#!/usr/bin/env python2
from gimpfu import *
from ctypes import *
from sys import argv, platform
import sys
# sys.stderr = open('C:/temp/python-fu-output.txt','a')
# sys.stdout=sys.stderr # So that they both go to the same file

def load_library (library_name):
    if platform == "linux" or platform == "linux2":
        library_name = library_name + '.so.0'
    elif platform == "win32":

and the script - just the upper case 
   SF-OPTION       "Superpixels Color" '("average" "random")

I will attach the files I used, just in case.
More linux testers needed.

As a test I called gegl up in the BIMP dialog, get both and seems to work: It might bring new life back to BIMP.

Attached Files
.zip (Size: 3.29 KB / Downloads: 287)
Thank you rich2005
I was hoping Ofnuts for code advice and tmanni as the "Resident GEGL Expert" might have commented.

So I'll save this up for the next time someone asks if a GEGL operation is scriptable.
Well I've just discovered that I can simplify the whole thing because you can send GEGL the same string as is entered in the GEGL graph, thus leaving the constructing of the parameter list up to the script-writer.

Code to follow...
OK here's the code

.zip (Size: 2.84 KB / Downloads: 549)

The python creates a new PDB entry for gegl-gegl:

The .scm just gives a demo call of gegl-gegl that illustrates that the string to pass is the same as is used manually with the GEGL graph

I think the issue with the dynamic library name is going to cause problems for Linux users.

That works ok here: kbuntu 18.04 / Gimp 2.10.18


I did write the GEGL operations on separate lines in your script, rather than use /n linefeeds

The question.  
A search + deb or +  rpm  gets a reference to the libgimp2.0-dev package which is not installed by default. Need to compile a plugin?  Get the dev package.
Fedora / CentOS / Mageia, etc rpm packages the same. I think safe to assume the average linux user will have

Forum Jump: