12-30-2021, 04:56 PM
To transform the layer to a tensor or numpy or any other standard python information I decide to store it as PNG and after some computation I will load it, but the load functions seams not towork:
It gets a gimp error that says that I try to add a layer to an incorrect image (it seems because img is different from image). I attached the full example code.
How do I load a png as a layer correctly?
Code:
save_image(image, drawable, os.path.join(base_dir, "cache.png"))
img = load_image(os.path.join(base_dir, "cache.png"))
layer = Gimp.Layer.new(
img, 'loaded',
drawable.get_width(), drawable.get_height(),
Gimp.ImageType.RGBA_IMAGE, 100.0,
Gimp.LayerMode.NORMAL
)
position = Gimp.get_pdb().run_procedure('gimp-image-get-item-position',
[image,
drawable]).index(1)
image.insert_layer(layer,None,position)
How do I load a png as a layer correctly?