Lomo-Gimp is a script-fu for the GIMP that tries to enrich pictures taken using a digital camera with the warmth of those taken with a classic analog camera.
The following tutorial was written back in 2000 and newer versions of Gimp might not fully support the examples given here. Bug reports can be submitted to the Script-fu Tutorial Table of Content. Preface The following tutorial is written for The Gimp 1.1.24.
![How To Get Script Fu How To Get Script Fu](/uploads/1/2/5/4/125452403/298793003.png)
Some things described here will not work or will work differently with The Gimp 1.0.x. Introduction This is a short tutorial in Script-Fu programming. I'll try to give a short intro into the world of Script-Fu and explain how basic things works. We will create a complete script-fu step-by-step. The goal is to have a Script-Fu, which produces a metal style text.
I assume, that the reader has a basic knowlege of Scheme, which is the programming language that is used in Script-Fu First step on the road to a Script-Fu Ok, now we take the first step:what we want to do in Script-Fu, we try to do first in The Gimp as normal. That is important, 'cause we need to know exactly which operation we need, and in which order we need to call them. So let's create our test image, first of we create a new rgb image ( File-New Image) and insert some text into it, say the word 'Test'. Then we duplicate the text and apply a metal gradient to the top layer. Then we take the second text layer and enlarge it a bit, to do so, we use the alpha-to-selection function and grow the selection by a few pixels.
Then we fill the selection with the same gradient, but in a another orientation. At last, we merge the layers and apply a standard drop shadow. When that is done, we auto-crop the image, to remove all unnecessary parts of the image. Reproducing the steps in the Script-Fu Console Ok: the image looks now as we expected it to, so lets summarize what we have done:. Create an new image.
Create a text layer. Duplicate the text layer. Enlarge the bottom text layer.
Fill both text layers with a gradient. Merge the text layers. Apply a drop shadow.
Merge all layers. Auto-crop the image The task is now to reproduce these steps in the Script-Fu Console: where you can enter Script-Fu Commands and test them.
Use the Console to test all new functions you aren't handy with; in the Console you can more or less debug your written scripts. It's easiest if you test every line of Script-Fu first in the Console and then parallel-write the Script-Fu, once the commands act as you expect them to.
To do so, we open the Script-Fu Console ( Xtns-Script-fu-Consol). When the console is open, we click on the Browse. Button in the bottom left corner; this brings us to the DB Browser, where you can search for functions which you can access from within Script-Fu. Along with the name of the function, you also get a description of the arguments it expects and a general description what the function does. Now it's time to reproduce our first step in the image creation, so we need a function to create an new image. Most of the functions you find in the DB Browser have names similar to those in the menus of the Gimp.
After a little search for 'new' we find the function gimp-image-new, which sounds like what we are searching for. We enter the following into the console: (gimp-image-new 256 256 RGB) and we will get an output as follows: = (gimp-image-new 256 256 RGB) (3) The first line is simply the command that was executed, the second line is the return value of the function. As you can read in the DB Browser, this is the ID of the newly created image. You can simply use the ID as an argument to functions in the console.
The return value is also the first pitfall on our journey to Script-Fu. It comes as a one element long list and not as a integer value!
So to use the value, we have to get the first element of the list with car, it will then return the image with ID 3. You might now wonder, where the image is that we have created, 'cause you cannot see it.
The answer is: we don't have a display for it, so the image is only inside the memory, but is not displayed, so we need create an display for it. So we try (gimp-display-new 3), but we get an error: ERROR: Procedural database execution failed: (gimpdisplaynew 3) So, that's just another pitfall. Not all functions in Script-Fu, act the same as their counterparts in the menus. Sometimes they are much more low-level, so you have to do some more work, to get the results you expect. The problem here is that our newly created image doesn't contain any layers.
To display an image, we actually need at least one layer. So the next step is to create an layer: = (gimp-layer-new 3 256 256 RGB-IMAGE 'foobar' 100 NORMAL-MODE) (21) You might notice that the constants RGB-IMAGE and NORMAL-MODE is listed as RGBIMAGE and NORMALMODE in the DB Browser (notice the underscore ').
You have to replace all the underscrores with minus's '-' in the Script-Fu world. If your are unsure if your replacements are right, just enter the constant into the console. The next step is to add the newly created layer to the image, as described in the DB browser: = (gimp-image-add-layer 3 21 -1) And now we can finally display our image: = (gimp-display-new 3) (4) The displayed image looks a bit wierd, cause it is filled with random colors, to erase them, we will fill the layer with the current background color. = (gimp-drawable-fill 21 BG-IMAGE-FILL) The function to fill a layer is called gimp-drawable-fill and not gimp-layer-fill as you might expect, that's because a layer is a drawable. So if you are searching for functions to manipulate layers, you should also look out for stuff that manipulates drawables. Now we have our image set up. To quick for you?
Then lets summarize and write our first scheme function. First we encapsule all of it into a let. clause, and than add the let. clause into a function body: (define (my-make-new-image) (let. ((image (car (gimp-image-new 256 256 RGB))) (layer (car (gimp-layer-new image 256 256 RGB-IMAGE 'foobar' 100 NORMAL-MODE)))) (gimp-drawable-fill layer BG-IMAGE-FILL) (gimp-image-add-layer image layer 0) (gimp-display-new image) image)) The last line in a scheme function is the return value, so image is the return value in this function.
So back to our metal-text thing, we need now to add a text string and play with it. A little browsing in the DB brings up gimp-text-fontname. To call it we type: = (gimp-text-fontname 3 21 -1 0 'Foobar' 0 TRUE 25 PIXELS '-freefont-blippo-heavy-r-normal-.-24-.-.-.-p-.-iso8859-1') (33) And voila, we have our text on a newly created layer. The string '-freefont-blippo-heavy-r-normal-.-24-.-.-.-p-.-iso8859-1' might look like black-magic to you, but we will see later an easy way to create it.