GIMP 2.10/ Python2 possible to chose and insert an already opened image into the firts one via script?

What I want to do is this:
I have a main image open, also a second one that I want to insert to the first one.
In the registration part I use PF_Image fields for both.
The main image is retrieved automatically ( as it’s the first parameter in the register function).
But how do I proceed with the second one?
something like this?

pdb.gimp_file_load_layer(image, corner_image)

Any help appreciated.

The functionality you’re looking for is ‘open as layers” - looks like that’s gimp-file-load-layer, according to the procedure browser.

That works for files like xyz.png, but not for opened images.

If the image is already opened, select all, copy, then in the main image paste as a new layer, and then merge the layer down, maybe?

In fact you probably want to insert a layer from the second image into the first one… A second PF_LAYER argument will let you pick an image and a layer in that image.

Once you have that layer, you use

layer_to_image1 = pdb.gimp_layer_new_from_drawable(layer_from_image2, image1)

image1.insert_layer(layer_to_image1,...).

If you use a PF_IMAGE, you have to determine which layer (image2.active_layer or image2.layers[0] for instance), and then do as above, or iterate all layers in image2and copy them one by one.

Perfect solution as always.
Thanks a lot, Ofnuts.

1 Like