Posts: 9
Threads: 3
Joined: Mar 2022
Reputation:
0
Gimp version: 2.10
I want to apply a set of operations on all open images. Then I want to export the modified open images to a pdf.
What I tried: https://ideone.com/12JJYf
Error I got: https://ideone.com/XCprkE
Use some random parameters.
Posts: 1,511
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
04-01-2022, 04:41 AM
(This post was last modified: 04-01-2022, 05:06 AM by PixLab.)
file-pdf-save-multi requires an array of image ids and it seems you don't have it (your #comment I did strike shows you tried though)
images = gimp.image_list()
# num_images, image_ids = pdb.gimp_image_list()
pdb.file_pdf_save_multi(len(images), images, False, False, False, filename, filename)
you should have something alike
images = gimp.image_list()
images_ids = [img.ID for img in images]
pdb.file_pdf_save_multi(len(images), images_ids, False, False, False, filename, filename)
https://www.gimpusers.com/forums/gimp-us...save-multi
there is also an interesting discussion there ➤ http://gimpchat.com/viewtopic.php?f=9&t=12418
Posts: 7,131
Threads: 155
Joined: Oct 2016
Reputation:
1,003
Operating system(s):
Gimp version: 2.10
There is a reference to python3 in the error ? Maybe a conflict with Gimp python2.7
Posts: 9
Threads: 3
Joined: Mar 2022
Reputation:
0
Gimp version: 2.10
04-01-2022, 08:32 AM
(This post was last modified: 04-01-2022, 08:33 AM by billalmasum93.)
(04-01-2022, 04:41 AM)PixLab Wrote: file-pdf-save-multi requires an array of image ids and it seems you don't have it (your #comment I did strike shows you tried though)
images = gimp.image_list()
# num_images, image_ids = pdb.gimp_image_list()
pdb.file_pdf_save_multi(len(images), images, False, False, False, filename, filename)
you should have something alike
images = gimp.image_list()
images_ids = [img.ID for img in images]
pdb.file_pdf_save_multi(len(images), images_ids, False, False, False, filename, filename)
https://www.gimpusers.com/forums/gimp-us...save-multi
there is also an interesting discussion there ➤ http://gimpchat.com/viewtopic.php?f=9&t=12418
Thank you, it worked. I was getting error with pdb.gimp_image_list()
(04-01-2022, 07:44 AM)rich2005 Wrote: There is a reference to python3 in the error ? Maybe a conflict with Gimp python2.7
Can export now. I mainly needed to know about image.ID it seems. I forgot about it
Posts: 6,338
Threads: 272
Joined: Oct 2016
Reputation:
562
Operating system(s):
Gimp version: 2.10
Some remarks:
- Saving all images in sight isn't a very sound idea. You don't know what other unrelated images the user may have opened, and there could even be images created by scripts and not visible because not associated with a Display.
- If your script runs on all images it doesn't need a PF_IMAGE parameter
- The undo_group_start/undo_group_end isn't useful since it only applies to the initial image. If you want this you have to do it on subimage inside of the loop
- By contrast the gimp_context... calls applies to the "context" which is image-independent, so you can do this outside of the loop
- To properly restore the opacity, bracket the code with gimp_context_push/gimp_context_pop
- On the other hand I don't see where the opacity applies, it is typically used for Paint tools
Posts: 6,338
Threads: 272
Joined: Oct 2016
Reputation:
562
Operating system(s):
Gimp version: 2.10
(04-01-2022, 04:41 AM)PixLab Wrote: you should have something alike
images = gimp.image_list()
images_ids = [img.ID for img in images]
pdb.file_pdf_save_multi(len(images), images_ids, False, False, False, filename, filename)
This programming teacher says that there is a big bug in the making, because you are assuming that images and image_ids have the same length, and this can become false later on (for instance if you filter ilages on type/name/whatever).
Posts: 9
Threads: 3
Joined: Mar 2022
Reputation:
0
Gimp version: 2.10
(04-01-2022, 08:41 PM)Ofnuts Wrote: (04-01-2022, 04:41 AM)PixLab Wrote: you should have something alike
images = gimp.image_list()
images_ids = [img.ID for img in images]
pdb.file_pdf_save_multi(len(images), images_ids, False, False, False, filename, filename)
This programming teacher says that there is a big bug in the making, because you are assuming that images and image_ids have the same length, and this can become false later on (for instance if you filter ilages on type/name/whatever).
That can be a bug. I will switch to len(image_ids) and image_ids=[image_id for image_id in image_ids if image_id is not none]
Although in my case it shouldn’t make any difference. The reason is I will always apply same set of operations on all valid open pages and no pages will be deleted
Posts: 9
Threads: 3
Joined: Mar 2022
Reputation:
0
Gimp version: 2.10
(04-01-2022, 08:37 PM)Ofnuts Wrote: Some remarks:
- Saving all images in sight isn't a very sound idea. You don't know what other unrelated images the user may have opened, and there could even be images created by scripts and not visible because not associated with a Display.
- If your script runs on all images it doesn't need a PF_IMAGE parameter
- The undo_group_start/undo_group_end isn't useful since it only applies to the initial image. If you want this you have to do it on subimage inside of the loop
- By contrast the gimp_context... calls applies to the "context" which is image-independent, so you can do this outside of the loop
- To properly restore the opacity, bracket the code with gimp_context_push/gimp_context_pop
- On the other hand I don't see where the opacity applies, it is typically used for Paint tools
These are useful for me so I will go through each of them.
* I saved all open images because I did not know any other way of accessing the images after modifying them. Please let me know if there is a better way.
* I was wondering whether to keep it or not, I kept it initially because I was experimenting the noise effect with a single image.
* I initially did that inside the loop but then I saw in another post on stackexchange I think where someone said a single undo is enough so did this.
* I wanted to access the opacity/radius parameter that is used for different blur/noise effects. Opacity can be configured within plugins whereas radius has to be configured outside the plugin. Please let me know if there is a reliable way to do this. I didn't find the official documentation particularly self-containing for API information.
Posts: 6,338
Threads: 272
Joined: Oct 2016
Reputation:
562
Operating system(s):
Gimp version: 2.10
(04-02-2022, 03:46 PM)billalmasum93 Wrote: (04-01-2022, 08:37 PM)Ofnuts Wrote: Some remarks:
- Saving all images in sight isn't a very sound idea. You don't know what other unrelated images the user may have opened, and there could even be images created by scripts and not visible because not associated with a Display.
- If your script runs on all images it doesn't need a PF_IMAGE parameter
- The undo_group_start/undo_group_end isn't useful since it only applies to the initial image. If you want this you have to do it on subimage inside of the loop
- By contrast the gimp_context... calls applies to the "context" which is image-independent, so you can do this outside of the loop
- To properly restore the opacity, bracket the code with gimp_context_push/gimp_context_pop
- On the other hand I don't see where the opacity applies, it is typically used for Paint tools
These are useful for me so I will go through each of them.
* I saved all open images because I did not know any other way of accessing the images after modifying them. Please let me know if there is a better way.
* I was wondering whether to keep it or not, I kept it initially because I was experimenting the noise effect with a single image.
* I initially did that inside the loop but then I saw in another post on stackexchange I think where someone said a single undo is enough so did this.
* I wanted to access the opacity/radius parameter that is used for different blur/noise effects. Opacity can be configured within plugins whereas radius has to be configured outside the plugin. Please let me know if there is a reliable way to do this. I didn't find the official documentation particularly self-containing for API information.
- My first question is why the workflow is split over many images...
- Url of SO post?
- What specific plugins/tools are you talking about?
|