Re: [Gimp-user] Exact crop question

2008-04-22 Thread saulgoode
Quoting David Gowers <[EMAIL PROTECTED]>:

> You defined zac-autocrop correctly, but you haven't registered it with GIMP.
> See this link for an example.

If you are calling a Script-fu defined function from the command line,  
it is not required that the function be registered with the PDB. The  
definition will be loaded when Script-fu is initialized and the  
function made available within Script-fu. PDB registration is only  
necessary if you wish the defined function to be made available to  
plug-ins or scripts in other languages.

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Exact crop question

2008-04-22 Thread Zachary Leung
Thanks guys, I've figured out what to do from your pointers! Didn't
realize there's a difference between _ and -.

Zac
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Exact crop question

2008-04-22 Thread Kevin Cozens
Zachary Leung wrote:
> I tried something below, but that didn't work. =(
[snip]
> gimp -i -b '(plug_in_autocrop "movie0.jpg")'
> 
> (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)
> (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
> (gimp-image-delete image)))

 From a quick look at the above, the zac-autocrop function appears to be ok 
with one minor exception. You don't use _ in the names of functions in 
Script-Fu. 'plug_in_autocrop' should be 'plug-in-autocrop'.

If you wrote zac-autocrop to load, crop, and re-save your files, why does your 
GIMP command line shown above call plug-in-autocrop instead of zac-autocrop?

-- 
Cheers!

Kevin.

http://www.ve3syb.ca/   |"What are we going to do today, Borg?"
Owner of Elecraft K2 #2172  |"Same thing we always do, Pinkutus:
 |  Try to assimilate the world!"
#include  |  -Pinkutus & the Borg
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Exact crop question

2008-04-22 Thread David Gowers
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 "movie0.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.
http://svn.gnome.org/viewvc/gimp/trunk/plug-ins/script-fu/scripts/paste-as-brush.scm?view=markup


Hope that helps!

David
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Exact crop question

2008-04-22 Thread Zachary Leung
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?

I tried something below, but that didn't work. =(

Thanks!

Zac

gimp -i -b '(plug_in_autocrop "movie0.jpg")'

(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)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))



On Tue, Apr 22, 2008 at 12:39 PM, David Gowers <[EMAIL PROTECTED]> wrote:
> Hi Zac!
>
>
> On Tue, Apr 22, 2008 at 1:45 PM, Zachary Leung <[EMAIL PROTECTED]> wrote:
> > Hi everyone,
> >
> > I'm wondering if there's an automated way to crop my images of all the white
> > areas on the outside.
> >
> > Basically I've produced quite a few MATLAB plots exported as JPEGs. There's
> > a lot of white around the sides, and the figure is in the center. Is there
> > an automated way to crop exactly the white parts around the figure away?
> > That would save me time from having to zoom in to each picture and do the
> > cropping manually.
> Autocrop (Image->Autocrop) does this.
>
> David
>



-- 
Blessed is the one who finds wisdom,
 and the one who gets understanding,
for the gain from her is better than gain from silver
 and her profit better than gold.
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Exact crop question

2008-04-21 Thread David Gowers
Hi Zac!

On Tue, Apr 22, 2008 at 1:45 PM, Zachary Leung <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm wondering if there's an automated way to crop my images of all the white
> areas on the outside.
>
> Basically I've produced quite a few MATLAB plots exported as JPEGs. There's
> a lot of white around the sides, and the figure is in the center. Is there
> an automated way to crop exactly the white parts around the figure away?
> That would save me time from having to zoom in to each picture and do the
> cropping manually.
Autocrop (Image->Autocrop) does this.

David
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user