Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learn to create Python3 plugins
#11
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:
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)
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?


Attached Files
.txt   save_and_load.txt (Size: 6.94 KB / Downloads: 187)
Reply


Messages In This Thread
Learn to create Python3 plugins - by z-uo - 12-27-2021, 09:59 AM
RE: Learn to create Python3 plugins - by z-uo - 12-27-2021, 04:12 PM
RE: Learn to create Python3 plugins - by z-uo - 12-28-2021, 11:14 AM
RE: Learn to create Python3 plugins - by z-uo - 12-28-2021, 07:27 PM
RE: Learn to create Python3 plugins - by z-uo - 12-29-2021, 05:07 PM
RE: Learn to create Python3 plugins - by z-uo - 12-30-2021, 10:16 AM
RE: Learn to create Python3 plugins - by z-uo - 12-30-2021, 04:56 PM
RE: Learn to create Python3 plugins - by z-uo - 12-30-2021, 05:54 PM
RE: Learn to create Python3 plugins - by z-uo - 12-31-2021, 08:40 AM
RE: Learn to create Python3 plugins - by z-uo - 01-02-2022, 10:37 AM

Forum Jump: