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


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