Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
12-21-2023, 12:19 AM
(This post was last modified: 02-18-2024, 12:55 PM by Ofnuts.)
I did some changes due to a suggestion made by Michael Schumacher from the GIMP team on reddit over there > https://www.reddit.com/r/GIMP/comments/1...?context=3
There was a potential inconvenience when exporting all images THEN when closing GIMP or closing an exported image, GIMP would not ask if you want to save the XCF, which can be inconvenient
I added this option, it is set by default after exporting an image then closing it, or closing GIMP, that GIMP will ask you if you want to save the XCF,
Untick this option and GIMP will not ask you this thus not saving the GIMP's XCF
here is the latest script, with the manual > I did updated the manual as well, it's a good read
https://gitlab.com/_PixLab/GIMP-Export-All-Images-As
Patrice
Posts: 1,046
Threads: 87
Joined: Aug 2018
Reputation:
83
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
01-23-2024, 12:43 PM
Hi PixLab,
I needed this functionality today and found this plugin of yours!
Luckily for me it is .scm so I didn't even need to manually export what was already ready, I could install the script without closing Gimp.
Just 2 observations:
In addition to exporting all open images (which was what I wanted), the script also exported 2 non-existent images!
Another thing is that it (the script) numbered the last open image to the first (from the rightmost image to the leftmost image on the screen).
As a result, the numbering next to the image names was reversed.
I must also highlight the excellent tutorial on how to use the script that you made available!
Thx!
.....
Samj Portable - Gimp 2.10.28 - Win-10 /64.
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
(01-23-2024, 12:43 PM)Krikor Wrote: In addition to exporting all open images (which was what I wanted), the script also exported 2 non-existent images!
No, it exported two images that had no associated view/display. These images are probably left-overs from a script that creates temporary work images and forgot to delete them (or crashed before it got to that).
See Windows > Dockable dialog > Images for a list of images currently in Gimp (with or without associated display).
Posts: 1,046
Threads: 87
Joined: Aug 2018
Reputation:
83
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
01-24-2024, 02:32 PM
(01-23-2024, 09:32 PM)Ofnuts Wrote: (01-23-2024, 12:43 PM)Krikor Wrote: In addition to exporting all open images (which was what I wanted), the script also exported 2 non-existent images!
No, it exported two images that had no associated view/display. These images are probably left-overs from a script that creates temporary work images and forgot to delete them (or crashed before it got to that).
See Windows > Dockable dialog > Images for a list of images currently in Gimp (with or without associated display).
Salut Ofnuts,
Exactly!
I knew that it was an image that I had used before and that for some reason it was still in Gimp's memory. It has happened before that I closed all the images and out of nowhere some layers appeared in the layers window that should no longer exist (the canvas was empty).
But I was unaware of this possibility of checking via ➤ Windows > Dockable dialog > Images
Now I went to check and those images were still there. I deleted them. I think this time definitely.
Now I will make a habit of checking this window (Images) more often.
Ofnuts, this information was very useful, thx a lot!
.....
Samj Portable - Gimp 2.10.28 - Win-10 /64.
Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
01-27-2024, 08:13 AM
(This post was last modified: 01-27-2024, 08:18 AM by PixLab.)
(01-23-2024, 09:32 PM)Ofnuts Wrote: (01-23-2024, 12:43 PM)Krikor Wrote: In addition to exporting all open images (which was what I wanted), the script also exported 2 non-existent images!
No, it exported two images that had no associated view/display. These images are probably left-overs from a script that creates temporary work images and forgot to delete them (or crashed before it got to that).
See Windows > Dockable dialog > Images for a list of images currently in Gimp (with or without associated display).
Thanks Ofnuts, valuable infos, I would have never ever thought about that, thanks again.
@Krikor, thanks for trying out that script, my first "full" script, that was an exercise, took a while to understand many things in tinyscript, though, but I'm glad that it can help.
Patrice
Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
01-28-2024, 04:19 AM
(This post was last modified: 01-28-2024, 04:34 AM by PixLab.)
(01-27-2024, 08:13 AM)PixLab Wrote: (01-23-2024, 09:32 PM)Ofnuts Wrote: These images are probably left-overs from a script that creates temporary work images and forgot to delete them
Thanks Ofnuts, valuable infos, I would have never ever thought about that, thanks again.
Wow.. the Beautify plugins left a LOT of non visible images, like a LOT.... for each time you test a filter in this plugin
@Ofnuts I saw at the bottom of the dialog that those "hidden" images have the red X active, thus they can be deleted, does it means that with a script (python/tinyscript) they can be filtered out?
Patrice
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
(01-28-2024, 04:19 AM)PixLab Wrote: (01-27-2024, 08:13 AM)PixLab Wrote: (01-23-2024, 09:32 PM)Ofnuts Wrote: These images are probably left-overs from a script that creates temporary work images and forgot to delete them
Thanks Ofnuts, valuable infos, I would have never ever thought about that, thanks again.
Wow.. the Beautify plugins left a LOT of non visible images, like a LOT.... for each time you test a filter in this plugin
@Ofnuts I saw at the bottom of the dialog that those "hidden" images have the red X active, thus they can be deleted, does it means that with a script (python/tinyscript) they can be filtered out?
Don't even need a script, just enter this in the Python console:
Code:
for i in gimp.image_list(): gimp.delete(i)
and strike [enter] twice. This will delete all images that you didn't create by user interaction, and leave the rest alone.
Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
(01-28-2024, 12:13 PM)Ofnuts Wrote: Don't even need a script, just enter this in the Python console:
Code:
for i in gimp.image_list(): gimp.delete(i)
and strike [enter] twice. This will delete all images that you didn't create by user interaction, and leave the rest alone.
I asked with a script because It's to eventually update that scm to clean all those images up before exporting all, for what happened to Krikor does not happen (now i'll try to find a way to translate that in tinyscript which I really hate this language )
In all case thanks a lot Ofnuts, very much appreciated that line of code
Patrice
Posts: 6,340
Threads: 272
Joined: Oct 2016
Reputation:
563
Operating system(s):
Gimp version: 2.10
(01-29-2024, 05:27 AM)PixLab Wrote: I asked with a script because It's to eventually update that scm to clean all those images up before exporting all, for what happened to Krikor does not happen
Bad idea IMHO. Deleting stuff is always dangerous. You may solve Krikor's problem, but this puts the images of everybody else in Jeopardy. Lingering images are more general problem. If Krikor has lingering images, then he should complain to the author of the plugin that generates them, or clean them by hand, or clean them with an ad-hoc script, or stop using buggy plugins.
The best you can do is to refuse to run with a message if you find more images than displays. Possible technique:
- List all images, and count them
- Obtain their IDs, and find the maximum ID. This gives you a count of all images that have been opened in that Gimp session. Since both image IDs and display IDs are allocated in sequence the max display ID isn't very far from the max Image ID.
- Iterate all numbers to the max Image ID, plus some margin, say, 20, and count those for which (gimp-display-is-valid display) is true. This gives you the number of active displays
- If you have more image than displays, bail out.
- Of course there may be rare cases of people using several displays on one image, and this would mask display less images, but missing that makes you export a couple of extra images, not delete things by mistake.
Posts: 1,512
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
01-29-2024, 10:14 AM
(This post was last modified: 01-29-2024, 10:18 AM by PixLab.)
(01-29-2024, 08:50 AM)Ofnuts Wrote: (01-29-2024, 05:27 AM)PixLab Wrote: I asked with a script because It's to eventually update that scm to clean all those images up before exporting all, for what happened to Krikor does not happen
Bad idea IMHO. Deleting stuff is always dangerous. You may solve Krikor's problem, but this puts the images of everybody else in Jeopardy. Lingering images are more general problem. If Krikor has lingering images, then he should complain to the author of the plugin that generates them, or clean them by hand, or clean them with an ad-hoc script, or stop using buggy plugins.
The best you can do is to refuse to run with a message if you find more images than displays. Possible technique:
- List all images, and count them
- Obtain their IDs, and find the maximum ID. This gives you a count of all images that have been opened in that Gimp session. Since both image IDs and display IDs are allocated in sequence the max display ID isn't very far from the max Image ID.
- Iterate all numbers to the max Image ID, plus some margin, say, 20, and count those for which (gimp-display-is-valid display) is true. This gives you the number of active displays
- If you have more image than displays, bail out.
- Of course there may be rare cases of people using several displays on one image, and this would mask display less images, but missing that makes you export a couple of extra images, not delete things by mistake.
Deleting stuff is always dangerous, Wow.. this sentence wakes me up, indeed you're absolutely right, I cannot even imagine what people did before using that script, thus it could mess something.
I'm gonna look in the bailout solution you are speaking about as an exercise (but not today ).
And again thanks a LOT for those excellent advises, and possible solutions
Patrice
|