1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

GIMP SCRIPT-FU Basics

Discussion in 'Gimp Tips & Tutorials' started by humblejohnny20, Jan 9, 2011.

  1. humblejohnny20

    humblejohnny20 Member

    Joined:
    Nov 17, 2010
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    These are the basics of gimp script-fu.

    Actually, its more important to start with plain scheme, which you need to make good quality scripts, so here are the basics:

    1. Open gimp, click: filters -> script-fu -> console

    [​IMG]


    important tip : here you can test commands and get instant feedback!

    2. Paste commands into console!

    Paste this:

    Code:
     (define Freddy)
    
    freddy is initialized
    now this

    Code:
     (set! Freddy 999) 
    freddy's value has been set
    now it will alert you of the true value of Freddy

    now paste this:

    Code:
    (= Freddy 1)
    it will say "#f" - the statement is false - our variable doesn't equal 1, it's 999

    Code:
    (= Freddy 999)
    it will say "#t"

    Code:
    (+ 1 Freddy)
    Freddy now equals 1000

    Code:
    (* 2 Freddy)
    This one is weird. for me, gimp limits freddy at 1998 - is this the maximum integer length ???

    and lastly - a loop with an if statement - you can paste this all at once:

    Code:
    (let loop ((a 1))
    (if (< a 50)
    (begin
    (print a) (print "We are iterating through our loop!")
    (loop (+ a 1)))))
    
    in c++, my favorite language, but unrelated to gimp, you could just do:

    Code:
    int a=0;
    while(a<50)
    {
    a++;
    cout<<a;
    cout<<"We are iterating through our loop!";
    }
    
    warning - be careful with loops , as if you make a neverending loop by accident, you might have to close gimp - this has happened to me several times when making scripts.



    And another tool necessary for scripting:

    Help -> Procedure Browser

    -lists all commands for use in gimp and their variable types - it would take days to go through all of these

    With the commands in the procedure browser, you can resize layers, blur layers, or do almost anything you could do by hand.


    MORE TO COME

    EDIT:

    I should add that i'm a newb to script-fu also, so im still learning, but i have alot of other programming experience - c++, etc

    for gimperaven - I'm going to add those eventually harharhar.

    Don't be afraid to post with watever.
     
  2. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    i think this is a great idea!
    i would suggest that first you would teach us how to set up everything (cause i think you need to do some stuff first...) so we can apply our scripts and stuff...
    im gonna try to make my own script now ;D
    mostly since (m)uTorrent is stealing my internet..
    but first... minecraft!
    sorry for going slightly off topic!
    but onceagain, do the alpha omega stuff first!
     
  3. humblejohnny20

    humblejohnny20 Member

    Joined:
    Nov 17, 2010
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16

    Ya i'm kind of tired but ill try to add a bit more to the post sometime.

    set up everything ?

    Well, theres only the gimp scm folder locations, you can test scripts/commands in the console without altering those files tho.

    anyone know those scm locations? (im feeling super lazy, just got bak from work 8O )

    on ubunto its something like /home/ubuntu/.gimp-2.6/scripts (you have to press ctrl-h to enable hidden files)

    on windowz i forget the location. its in prog files somewhere.

    idk where tis on mac.

    or by set up do you mean like defining the per-script variables, functions, options, etc.?
     

Share This Page