Working with Gimp Script-Fu is not very hard.
I will use Gimp 2.8 to make this simple tutorial.
It needs to understand how script-fu working and what can do for you.
Most of the users think the working with gimp is just tools, layers, buttons and nothing else.
Now I will show you how can improve your work with Gimp Script-Fu.
To working with Script-Fu it needs to go to the menu: Filters – Script-Fu – Console
First, you need to know it’s the Script-Fu has some syntax programming.
I will show some basic arithmetic operations like addition, subtraction, multiplication and more…
Let’s see how to do that:
addition
1 | (+ 11 1) |
subtraction
1 | (- 31 1) |
multiplication
1 | (* 11 3) |
division
1 | (/ 21 3) |
When you need to use some vars then you can use this:
1 | (define var1 61) |
Let’s see the result :
You can use also many functions like :
1 2 3 4 5 6 7 8 9 10 | > (integer? var1) #t > (define word1 "hello") word1 > (integer? word1) #f > (random 10) 1 > (random 10) 4 |
The ? is used to test if var1 is an integer and the result is #t (t from true).
Also, we can define a var named word1 = “hello”.
The #f show us the result of (integer? word1) is false.
And if we need to create random values then is used a random function.
Gimp also has many functions. You can see all if go to menu Help Procedure Browser.
But this is theory so let make now something more advanced.
Close the old console and open it again.
Make a file named Ex001.scm into your Gimp folder scripts ( C:\Program Files\GIMP 2\share\gimp\2.0\scripts\ ) and add this source script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ; "Hello, World" Test ; ; Creates an image with the text "Hello, World!" ; Copyright 2017, author Cătălin George Feștilă ; free-tutorials.org ; free to use with a Creative Commons (CC) license (define (script-fu-001 text font size colour) (gimp-context-push) (gimp-context-set-foreground colour) (let* ( ; initial image size is 32x32 - resize it later (img (car (gimp-image-new 32 32 RGB))) (dummy (gimp-image-undo-disable img)) (text-layer (car (gimp-text-fontname img -1 0 0 text 10 TRUE size PIXELS font))) (width (car (gimp-drawable-width text-layer))) (height (car (gimp-drawable-height text-layer))) ) ; resize image (gimp-image-resize img width height 0 0) (gimp-image-undo-enable img) (gimp-display-new img) (gimp-context-pop) )) (script-fu-register "script-fu-001" "free-tutorils ex. 001" "Creates an image with a user specified text string." "Cătălin George Feștilă <catafest@yahoo.com>" "Cătălin George Feștilă" "03 july, 2017" "" SF-STRING "Text string" "Example 001!" SF-FONT "Font" "Sans" SF-ADJUSTMENT "Font size (pixels)" '(100 2 1000 1 10 0 1) SF-COLOR "Color" '(255 0 0) ) (script-fu-menu-register "script-fu-001" "<Image>/File/Create") |
After restart your Gimp application the script can be found into Main Menu – File – Create:
The result when I run the Script-Fu script is this window dialog:
The output of this script with setting from free-tutorials ex.001 :
There are many web sites on the Internet with information relating to the Script-Fu scripts and plugins.
Is more good for you to learn the basic of Script-Fu – this helps you to make your own area of work with graphics.
When you try someone else’s work most of the time you choose with errors or incomplete output.
Knowing how to create and program scripts Script-Fu in the Gimp application can help you create both: the desired content and the assimilation of content taken from the internet.