Sunday, May 30, 2010

My First Script-Fu Script 4,
Registering a Function

 
This morning I'm trying to
figure out the script-fu-register
function. Since this function is so
very fundamental to Script-Fu, I thought
I should know something about it.

I'm using this web page as my reference
as I try to figure out script-fu-register
and the arguments to script-fu-register:

3.4.5. Registering The Function

You'll have to scroll down the page a bit to see
Section 3.4.5. This is the section that
describes the script-fu-register function.

From what I read, I gather that the parameters
to script-fu-register are divided into
two categories:

  1. The first 7 (required) parameters
  2. The parameters (optional) that are
    passed into the script-fu script itself

In other words, the first 7 parameters are
required. The 8th parameter, if there is
one, would be the first argument to the
Script-Fu script itself.

For those familiar with C Language, I'm going
to assume something here. It is my assumption
that parameter number 8 and beyond are
functionally equivalent to the arguments
to the C Language main() function.

Clearly you do not need anything but the
first 7 parameters if you are writing an
interactive Script-Fu script. That's my
assumption. I assume that you only use
parameters number 8 and beyond if you are
doing some kind of command line call.

In other words, I'm assuming that parameters
number 8 and beyond become valuable when
you go to a higher level of automation.
For example, you might want to use Script-Fu
to batch process a series of 100 images. To
do this, having the ability to pass arguments
in via the command line is very valuable.

My assumption is that arguments number 8 and
beyond become valuable when you go to a higher
level of automation, such as processing multiple
images serially with no user interaction whatsoever.

OK. Back to the required arguments to
script-fu-register. The first 7
required arguments appear to me to be
more than sufficient if all you are going
to do is process the current image interactively.
That is to say, you are planning to interact
with the current image yourself inside of the
Gimp user interface.

The Gimp user interface is where you normally
do things to images. For the normal Gimp user,
the normal Gimp user interface is the normal place
to be. The first 7 arguments to script-fu-register
will suffice for the normal Gimp user interacting
with the normal Gimp user interface.

Here are the 7 arguments given in the order in
which they appear:

  1. The name of the entry function.
    All functions are called from this
    master function.
  2. The menu location for
    the script
  3. A description that documents
    the script
  4. Your name as author of
    the script
  5. Your copyright notice for
    your script
  6. The date you created your
    script
  7. The image type the script
    works on. If no image type is
    applicable, it appears to me that
    a double asterisk will suffice

OK. Those are the 7 parameters to
register-script-fu. These parameters
are so important that it would seem that
they are required for every single
Script-Fu script that you will
ever write.

This is my assumption. Later, I may
have to go back and correct any false
assumptions I've made in this post.

This post is written by a Script-Fu
newbie. I'm learning Script-Fu as I
go.

Ed Abbott

No comments:

Post a Comment