Hi Zachary,

On Tue, Apr 22, 2008 at 6:27 PM, Zachary Leung <[EMAIL PROTECTED]> wrote:
> Hi David,
>  Thanks for answering my question so quickly.
>  I realized that I should have phrased my question more carefully. What
>  I want is to be able to autocrop all the images matching a pattern,
>  say "movie*.jpg". How do I do that?

script-fu is something I do not use, so I will give my example
implementation in a form that you could call from the PyGimp console.

def autocrop_many (pattern):
  import glob
  filenames = glob.glob (pattern)
  for filename in filenames:
    #the following is a direct translation of your script-fu.
    image = pdb.gimp_file_load (filename, filename)
    drawable = image.active_layer
    pdb.plug_in_autocrop (image, drawable)
    pdb.gimp_file_save (image, drawable, filename, filename)
    pdb.gimp_image_delete (image) # this line may not be needed

If you paste the above into a PyGimp console, then call it like
autocrop_many ('/path/to/files/movie*')
it should do what you want.

If you don't have python support installed, I can only help by
pointing out basic errors in your code; I know little of script-fu

>  I tried something below, but that didn't work. =(
>  Thanks!
>  Zac
>  gimp -i -b '(plug_in_autocrop "movie00000.jpg")'

* plug_in_autocrop accepts an image as it's first parameter, but you
provided a filename.
(you also are trying to call 'plug_in_autocrop', whereas the function
is named 'plug-in-autocrop'. -/_ substitution is only used if you're
coding your plugin in Python.)
 I think you meant to call zac-autocrop here, anyway.

>  (define (zac-autocrop filename)
>   (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
>          (drawable (car (gimp-image-get-active-layer image))))
>     (plug_in_autocrop RUN-NONINTERACTIVE image drawable)
the above line has the _ / - mistake I pointed out earlier in this email.

>     (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
>     (gimp-image-delete image)))
You defined zac-autocrop correctly, but you haven't registered it with GIMP.
See this link for an example.

Hope that helps!

Gimp-user mailing list

Reply via email to