10-08-2024, 09:09 PM
(10-08-2024, 07:47 PM)Ofnuts Wrote:(10-08-2024, 07:29 PM)ttt Wrote: I played around with this and notice the function file_fits_load returns one image but it creates 3 in memory which you can use compose them as RGB.
So i got this to work
def afittest(image,layer,file):
image = pdb.file_fits_load(file,file)
#images set in memory but not returned because return only one but we have 3 new images
l = gimp.image_list()
redImage = l[len(l)-2]
greenImage = l[len(l)-3]
blueImage = l[len(l)-4]
#compose them
new_image = pdb.plug_in_compose(redImage,layer,greenImage,blueImage,redImage,"RGB")
pdb.gimp_display_new(new_image)
In Python you can use negative indexes to access list elements from the end: l[-1] is the last element, for instance. You can even use slices, so for instance: imgR,imgG,imgB=gimp.image_list()[-4:-1].
Otherwise, yes, the Images dockable dialog is your best friend, because it shows all images, even those that have no associated view/display, and there is even a button to create a view for the latter. It is also a nice way to check for lingering images after a script.
Thank you very much ttt and Ofnuts!!
I was not able to use slices, I have an error:
➤> imgR,imgG,imgB=gimp.image_list()[-4:-1]
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError: need more than 2 values to unpack
But using gimp.image_list()[-1] , gimp.image_list()[-2] and gimp.image_list()[-3] works like a charm.
With the example of ttt, I now have my RGB picture!
Thanks again!
Best regads,
Damien.