The PDB documentation / naming convention is quite the opposite if you are trying to do something with python in gimp and are hard to understand. I ended up finding gimp.GroupLayer (PDB lists gimp-layer-group-new ) to create a new layer group. How do you paste this into an image, and do you display it as a group of layers?
I tried things like this:
img = gimp.image_list()[0] gl = gimp.GroupLayer(img, "Should be a folder", 1, 1, 0) img.insert_layer(gl)
The first thing that bothers me is that it expects me to specify height and width for GroupLayer, although it should just act as a container for other real layers (it expects this because it inherits from Layer , but thatβs another matter) .
The real problem is that when I insert the newly created GroupLayer , it appears as a normal layer (there is no folder on the layer icon). I checked this by creating two layers: one is normal, one is group. I add a group layer to the image, and then try to add a normal layer to the image with the group layer as the parent:
img = gimp.image_list()[0] gl = gimp.GroupLayer(img, "Group Layer", 1, 1, 0) l = gimp.Layer(img, "Real Layer", 1, 1, 0) img.insert_layer(gl) img.insert_layer(l, gl)
All I get is an error:
Calling error for procedure 'gimp-image-insert-layer': Item 'group layer #1' (34) cannot be used because it is not a group item`
Has anyone else figured this out?
UPDATE
Joao S.O. Bueno
I just fixed this problem in gimp-git. Frgom gimp 2.8.12 on,
The call to gimp.GroupLayer works with the gimp.GroupLayer(img, [name="", opacity=100.0, mode=gimp.NORMAL_MODE]) signature.