Re: [Gimp-user] 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
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.

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]