Hi, I am experimenting with Gimp scripting. I am testing to see how various procedures in the PDB work, using the
Python-Fu console (with the goal of writing some simple scripts in
python).
I am encountering a problem with "gimp-image-insert-layer" when I run the following code in the
Python-Fu console:
w = 3648
h = 2736
new_image = gimp.gdb.gimp_image_new(w, h, 0) #returns an IMAGE type
new_layer = gimp.gdb.gimp_layer_new(new_image, w, h, 0, "layer 1", 100, 0) #returns a LAYER type
gimp.gdb.gimp_image_insert_layer(new_image, new_layer, 0, -1)
When I run enter the last line (the call to "gimp_image_insert_layer"), I get the following error message:
Quote:
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: wrong parameter type
I also tried setting the position of the new layer to "0", but I get the same error:
w = 3648
h = 2736
new_image = gimp.gdb.gimp_image_new(w, h, 0)
new_layer = gimp.gdb.gimp_layer_new(new_image, w, h, 0, "layer 1", 100, 0)
gimp.gdb.gimp_image_insert_layer(new_image, new_layer, 0, 0)
A couple of years ago, when I was playing around with Gimp 2.6 and
python scripting, I was going thru a similar exercise using "gimp_image_add_layer" I did not have any problem (but "gimp_image_add_layer" has been depreciated and is not recognized by Gimp 2.8). The main difference in calling "gimp_image_insert_layer" or "gimp_image_add_layer" is the former has an extra parameter "parent layer". But my images is new and has no layers, parent or otherwise. The info in the PDB Browers suggests that "parent layer" relates to "layer groups", and if you do not have a group, or if the inserted layer is not part of a group, then "0" should be entered for that parameter (0=None).
I am pretty sure my types are okay, "gimp_image_insert_layer" requires 4 parameters: image (an IMAGE type), layer (a LAYER type), parent payer (a LAYER type) and position (INT32).
I have tried to find an answer on web, but cannot seem to find anything addressing why I am getting this error. I am sure I must be missing something obvious. Any help would be much appreciated.
Thanks.