Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting GEGL operations
#1
As someone eventually raised an issue about scripting GEGL: https://gitlab.gnome.org/GNOME/gimp/-/issues/1686 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
   

Thanks

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

I get error messages here:  https://i.imgur.com/gwwpk3J.jpg  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.

Code:
Querying plug-in: '/home/rich/gimp210/plugin-test/fu-python-gegl_ops_test.py' [/color]
Traceback (most recent call last):
 File "/home/rich/gimp210/plugin-test/fu-python-gegl_ops_test.py", line 6, in <modu
le>
   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/fu-python-gegl_ops_test.py'
Reply
#3
@rich2005

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

Try comenting out the lines at the top:
Code:
#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.
Reply
#4
yes, I assumed that. disabled that now this

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

looks like it should be libgimp-2.0.so.0
Reply
#5
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?
Reply
#6
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) libgimp-2.0.so.0 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

Code:
#!/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 
Code:
   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: https://i.imgur.com/SDYf9Tf.jpg It might bring new life back to BIMP.


Attached Files
.zip   gegl_ops_tested.py.zip (Size: 3.29 KB / Downloads: 325)
Reply
#7
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.
Reply
#8
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...
Reply
#9
OK here's the code

.zip   gegl_ops_test.zip (Size: 2.84 KB / Downloads: 596)

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.

   
Reply
#10
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 libgimp-2.0.so question.  
A search libgimp-2.0.so + 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.
example.  https://packages.debian.org/search?suite...imp-2.0.so
Fedora / CentOS / Mageia, etc rpm packages the same. I think safe to assume the average linux user will have  libgimp-2.0.so.0
Reply


Forum Jump: