kritiksoman / GIMP-ML

AI for GNU Image Manipulation Program
https://kritiksoman.github.io/GIMP-ML-Docs/index.html
MIT License
1.39k stars 126 forks source link

'Image' object has no attribute 'get_active_layer' #55

Closed gpavelski closed 1 year ago

gpavelski commented 1 year ago

Describe the bug I have successfully installed the GIMP developer version 2.99.14 and the plugins, I can see the plugins in the Layer Menu. But whenever I try to run any of the plugins, the CMD window returns:

(gimp-2.99.exe:47212): GLib-GIO-WARNING **: 10:57:39.767: win32 session dbus binary not found
set device 'System Aggregated Pointer' to mode: disabled
Skipping potential plug-in 'C:\Users\Guilherme\GIMP-ML\gimpenv3\Lib\site-packages\gimpml\plugins\plugin_utils.py': plug-ins must be installed in subdirectories.
Skipping potential plug-in 'C:\Users\Guilherme\GIMP-ML\gimpenv3\Lib\site-packages\gimpml\plugins\__init__.py': plug-ins must be installed in subdirectories.

jpeg-load: found Exif block (14993 bytes)
Traceback (most recent call last):
  File "C:\Users\Guilherme\GIMP-ML\gimpenv3\Lib\site-packages\gimpml\plugins\enlighten\enlighten.py", line 171, in run
    result = enlighten(
  File "C:\Users\Guilherme\GIMP-ML\gimpenv3\Lib\site-packages\gimpml\plugins\enlighten\enlighten.py", line 72, in enlighten
    result_layer = result.get_active_layer()
AttributeError: 'Image' object has no attribute 'get_active_layer'

(enlighten.py:42940): LibGimp-WARNING **: 10:58:15.761: gimp_procedure_run: no return values, shouldn't happen
C:\Users\Guilherme\GIMP-ML\gimpenv3\Lib\site-packages\gimpml\plugins\enlighten\enlighten.py:230: Warning: g_error_new: assertion 'domain != 0' failed
  Gimp.main(Enlighten.__gtype__, sys.argv)
gimp_plug_in_destroy_proxies: ERROR: GimpImage proxy with ID 1 was refed by plug-in, it MUST NOT do that!
gimp_plug_in_destroy_proxies: ERROR: GimpImage proxy with ID 2 was refed by plug-in, it MUST NOT do that!
gimp_plug_in_destroy_proxies: ERROR: GimpLayer proxy with ID 2 was refed by plug-in, it MUST NOT do that!

The problem happens when result.get_active_layer() is called:

result = Gimp.file_load( Gimp.RunMode.NONINTERACTIVE, Gio.file_new_for_path(os.path.join(weight_path, "..", "cache.png")), ) result_layer = result.get_active_layer()

What could be the issue? Can it be a conflict between the Image library and Gimp library?

Desktop (please complete the following information):

gpavelski commented 1 year ago

Actually, I already found the solution in this Pull Request.

The idea is to replace result_layer = result.get_active_layer() by result_layer = result.list_layers()[0] in all of the plugins python scripts.