interactive batch processing
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
interactive batch processing | Gary Aitken | 09 Dec 18:50 |
interactive batch processing | Bob Long | 09 Dec 23:38 |
interactive batch processing | Gary Aitken | 10 Dec 04:50 |
interactive batch processing | Akkana Peck | 10 Dec 02:06 |
interactive batch processing | Ofnuts | 12 Dec 11:06 |
interactive batch processing
In the past I have interactively batch processed images via a shell script that invokes gimp for each image. This is both inconvenient and slow. Inconvenient because there are parameters I need to enter into some python-fu scripts that are the same for each of the images, and slow because of the gimp startup and shutdown each time.
Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
B. I can feed the list of file names to a python-fu script, which then can open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.
It seems like gimp-display-get-window-handle might be useful somehow, if there were a means to be notified when the window is destroyed.
Any thoughts / hints would be much appreciated.
Thanks,
Gary
interactive batch processing
Gary Aitken wrote on 10/12/18 4:50 am:
In the past I have interactively batch processed images via a shell script
that invokes gimp for each image. This is both inconvenient and slow. Inconvenient because there are parameters I need to enter into some python-fu
scripts that are the same for each of the images, and slow because of the gimp startup and shutdown each time.Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
B. I can feed the list of file names to a python-fu script, which then can
open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before
opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.It seems like gimp-display-get-window-handle might be useful somehow, if there were a means to be notified when the window is destroyed.
Any thoughts / hints would be much appreciated.
Have a look at this script:
http://gimpchat.com/viewtopic.php?f=9&t=4846&p=183034&hilit=sequential_processing#p183034
Maybe that will do what you want.
Bob Long > > Thanks, > > Gary
interactive batch processing
Gary Aitken writes:
In the past I have interactively batch processed images via a shell script that invokes gimp for each image. This is both inconvenient and slow. Inconvenient because there are parameters I need to enter into some python-fu scripts that are the same for each of the images, and slow because of the gimp startup and shutdown each time.
Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
I don't know of one, though I would find it useful -- when processing a lot of images from a photo outing, for instance.
B. I can feed the list of file names to a python-fu script, which then can open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.
I don't know of a way to do that. However, you could do something like:
def wait_until_image_closed(filename):
'''Poll GIMP's image list, return when there's no longer an
open image connected to filename.
'''
while True:
for img in gimp.image_list():
if img.filename == cur_filename: # or whatever test you want
return
time.sleep(1)
Or better yet, get the current image before starting the loop, then loop until that image is no longer in the image list.
I know polling is slightly icky, but I've done it in several GIMP Python plug-ins when there was no notification available.
For this task, though, I'd be tempted to use an easier approach:
Start GIMP (with no files yet).
In a shell window, cd to the directory with the files I want to process, and do this (with whatever list of files you want):
for fil in *.jpg; do
gimp $fil
read x
done
The first file comes up as a GIMP window. Process it, and when you're ready for the next image, go to the shell window and hit return, and the next file comes up in GIMP.
It's not quite as clean since you still have to hit return for each image, but that's still a lot easier than navigating to each new image in the File->Open dialog.
...Akkana
interactive batch processing
On 12/9/18 4:38 PM, Bob Long wrote:
Gary Aitken wrote on 10/12/18 4:50 am:
...
Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
B. I can feed the list of file names to a python-fu script, which then can open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.
...
Have a look at this script:
http://gimpchat.com/viewtopic.php?f=9&t=4846&p=183034&hilit=sequential_processing#p183034
On 12/9/18 7:06 PM, Akkana Peck wrote:
Gary Aitken writes:
...
Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
I don't know of one, though I would find it useful -- when processing a lot of images from a photo outing, for instance.
B. I can feed the list of file names to a python-fu script, which then can open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.
I don't know of a way to do that. However, you could do something like:
def wait_until_image_closed(filename): '''Poll GIMP's image list, return when there's no longer an open image connected to filename. '''
while True:
for img in gimp.image_list(): if img.filename == cur_filename: # or whatever test you want return
time.sleep(1)Or better yet, get the current image before starting the loop, then loop until that image is no longer in the image list.
I know polling is slightly icky, but I've done it in several GIMP Python plug-ins when there was no notification available.
For this task, though, I'd be tempted to use an easier approach:
Start GIMP (with no files yet).
In a shell window, cd to the directory with the files I want to process, and do this (with whatever list of files you want):
for fil in *.jpg; do gimp $fil
read x
doneThe first file comes up as a GIMP window. Process it, and when you're ready for the next image, go to the shell window and hit return, and the next file comes up in GIMP.
It's not quite as clean since you still have to hit return for each image, but that's still a lot easier than navigating to each new image in the File->Open dialog.
Thanks both of you for your suggestions and pointers. I think all of those will enable me to work out a solution.
Thanks again.
Gary
interactive batch processing
On 12/9/18 7:50 PM, Gary Aitken wrote:
In the past I have interactively batch processed images via a shell script
that invokes gimp for each image. This is both inconvenient and slow. Inconvenient because there are parameters I need to enter into some python-fu
scripts that are the same for each of the images, and slow because of the gimp startup and shutdown each time.Is there a way to do one of the following:
A. Start gimp with a list of file names to process, and have it load only the first on the list. Then when one quits or closes the image, load the next one, etc?
B. I can feed the list of file names to a python-fu script, which then can
open and display the image. Is there a way for a python-fu script to wait for, or be notified of, the closing of an image display? This would allow the script to effectively pause and allow processing before
opening each successive image. gimp-context-push/pop seem like they may somehow enable this but it's not clear to me how they are used.It seems like gimp-display-get-window-handle might be useful somehow, if there were a means to be notified when the window is destroyed.
A) my own ofn-file-next script may help if the files are in some recognizable numerical sequence (IMG_678.JPG, IMG_679.JPG, IMG_690.JPG)(some holes in the sequence are allowed). You can assign it to some keyboard shortcut and it will export/close the current image, and load the next in the sequence. Typically you start Gimp, usin File>Ope, to open the first file in th eseqquence, and hit the shortcut to advance to the next file. Available here: .
This, combined with the "Repeat last filter" (Ctrl-F) (at the top of the "Filters" menu, repeats the last filter on the current image with the same parameters), should make you process your image sequence rather quickly (two keystrokes per image).
B) You can write a script that reads a list of files (or lists files in
a directory), and loads each file, applies a filter, and saves the
result. But you don't really change the behavior of the initial script.
gimp_context_{push|pop} have nothing to do with this, they are used to
save/restore the paint context (FG/BG colors, gradient, brush... etc).
An example here:
There is also a "BIMP" Gimp plugin (the B is for "Batch") that is supposed to be able to run Gimp commands over a series of files. I don't know how well it supports a random filter.