Tue Nov 06, 2012 6:06 am
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)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: wrong parameter type
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)
Tue Nov 06, 2012 6:44 am
Tue Nov 06, 2012 11:07 am
gatoruss wrote:I got this code to do what I intended.
I had been trying to solve this for a few hours. Most (if not all) of the stuff I found in the internet with coding examples using "gimp-image-insert-layer" were Script-Fu, and for situations where there was no "parent layer" a "0" was entered as the parameter for "parent layer." After I made the above post, I ran the code again, but used "None" rather than "0" for "parent layer," and it worked! I thought that I had tried "None" late last night but with no success - I must have been mistaken.
I wonder if the "None" vs. "0" distinction is a python thing?
gimp.gdb.gimp_image_insert_layer(new_image, new_layer, None, 0)
gimp.gdb.gimp_image_insert_layer(5, 12, 0, 0)
Tue Nov 06, 2012 12:44 pm
ofnuts wrote:It is consistent with the fact that in Python, the API doesn't take numeric object ids but objects references. In other words, it should be either:
- Code:
gimp.gdb.gimp_image_insert_layer(new_image, new_layer, None, 0)
or
- Code:
gimp.gdb.gimp_image_insert_layer(5, 12, 0, 0)
Tue Nov 06, 2012 3:28 pm
Tue Nov 06, 2012 7:40 pm
ofnuts wrote:To put in another way, the Scheme API takes zip codes, and the Python one takes city names
gimp.gdb.gimp_image_insert_layer(5, 12, 0, 0)
Wed Nov 07, 2012 2:01 am
Wed Nov 07, 2012 5:37 am
ofnuts wrote:Yes... the second alternative is what the code would look like if the Python API used the zip codes.
Fri Dec 01, 2017 1:08 am