12-28-2021, 05:38 PM
(12-28-2021, 11:14 AM)z-uo Wrote: Now I passed to the second point: Porting a python2 plugin to python3, but I find a problem on creating a simple transparent layer:
It say that image is not of type Gimp.ImageType:Code:
# ERROR add new trasparent layer
overlay_layer = Gimp.Layer.new(
image, 'hide_background',
drawable.get_width(), drawable.get_height(),
Gimp.ImageType, 100.0,
Gimp.LayerMode.NORMAL
)
overlay_layer.fill(Gimp.FillType.TRANSPARENT)
Code:
File "/home/opensuse/.var/app/org.gimp.GIMP/config/GIMP/2.99/plug-ins/add_baloon/add_baloon.py", line 114, in run
overlay_layer = Gimp.Layer.new(
TypeError: Expected a Gimp.ImageType, but got type
Why? What I do wrong?
The full code can be find here.
Code:
# ERROR add new trasparent layer
overlay_layer = Gimp.Layer.new(image, 'hide_background',
drawable.get_width(), drawable.get_height(),
Gimp.ImageType.RGBA_IMAGE, 100.0,
Gimp.LayerMode.NORMAL
)
result = Gimp.get_pdb().run_procedure('gimp-image-get-item-position',
[image,
drawable])
position = result.index (1)
image.insert_layer(overlay_layer,None,position)
overlay_layer.fill(Gimp.FillType.TRANSPARENT)
break
Threw me to start with - the problem wasn't with the first parameter (image) but the fifth parameter - the image type.
You also need to insert the new layer - it isn't sufficient to just create it.
The break statement is useful (at the moment anyway) to prevent an endless loop.
There are quite a few places where balloon only has one 'L'
There are also quite a few warnings that are shown in the terminal window that should be addressed.
Happy coding :-)