10.6. Undermenyn ”Script-Fu”
| 10. The ”Filters” Menu |

### 10.6. Undermenyn ”Script-Fu”

Figur 16.204. The ”Script-Fu” submenu

This submenu contains some Script-Fu commands, especially the Script-Fu console. Script-Fu is a language for writing scripts, which allow you to run a series of GIMP commands automatically.

#### 10.6.1. Activating the submenu

- You can access this command from the image menu through Filters → Script-Fu

#### 10.6.2. Uppdatera skripten

You will need this command every time you add, remove, or change a Script-Fu script. The command causes the Script-Fus to be reloaded and the menus containing Script-Fus to be rebuilt from scratch. If you don't use this command, GIMP won't notice your changes until you start it again.

Note that you won't get any feedback, unless saving, if one of your scripts fails.

#### 10.6.3. Script-Fu-konsoll

The Script-Fu console is a dialog window where you can interactively test Scheme commands.

The console consists of a large scrollable main window for output and a textbox used to type Scheme commands. When you type a Scheme statement and then press the Enter key, the command and its return value will be displayed in the main window.

Figur 16.205. Script-Fu-konsollen

You will find more information about Scheme and examples how to use the Script-Fu console in Avsnitt 3, ”A Script-Fu Tutorial”.

The Script-Fu Console Buttons

Bläddra

  This button is next to the Scheme commands textbox. When clicked, the procedure browser pops up, with an additional button at the bottom of the window:

  The additional button of the Procedure Browser

  When you press this Apply button in the procedure browser, the selected procedure will be pasted into the text box:

  Applied PDB procedure

  Now you just have to replace the parameter names (here: ”layer” and ”mode”) with actual values, and then you can call the procedure by pressing Enter.

Stäng

  Pressing this button closes the Script-Fu console.

Töm

  Wenn you click on this button, the content of the main window will be removed. Note that you can't get back the removed content using the Save command.

Spara

  This command lets you save the content of the main window, that is the Script-Fu console output (including the ”`>`”-characters).

#### 10.6.4. Start Server

This command will start a server, which reads and executes Script-Fu (Scheme) statements you send him via a specified port.

Figur 16.206. The Script-Fu Server Options

Serverport

  The port number where the Script-Fu server will listen. It is possible to start more than one server, specifying different port numbers, of course.

Server Logfile

  Optionally you can specify the name of a file the server will use to log informal and error messages. If no file is specified, messages will be written to stdout.

The Script-Fu Server Protocol

The protocol used to communicate with the Script-Fu server is very simple:

- Every message (Script-Fu statement) of length `L` sent to the server has to be preceded with the following 3 bytes:

  Tabell 16.1. Header format for commands

  Byte # | Innehåll | Beskrivning
  --- | --- | ---
  0 | 0x47 | Magic byte ('G')
  1 | L div 256 | High byte of `L`
  2 | L mod 256 | Low byte of `L`

- Every response from the server (return value or error message) of length `L` will be preceded with the following 4 bytes:

  Tabell 16.2. Header format for responses

  Byte # | Innehåll | Beskrivning
  --- | --- | ---
  0 | 0x47 | Magic byte ('G')
  1 | felkod | 0 on success, 1 on error
  2 | L div 256 | High byte of `L`
  3 | L mod 256 | Low byte of `L`

| Tips
If you don't want to get your hands dirty: there is a Python script named servertest.py shipped with the GIMP source code, which you can use as a simple command line shell for the Script-Fu server.

10.5. The ”Python-Fu” Submenu |  | 11. ”Windows” Menu

Report an error in Bugzilla