Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
Last active February 16, 2026 23:30
Show Gist options
  • Select an option

  • Save h4k1m0u/a7c7790e05c037bec614197da36c4d1e to your computer and use it in GitHub Desktop.

Select an option

Save h4k1m0u/a7c7790e05c037bec614197da36c4d1e to your computer and use it in GitHub Desktop.
Notes about the Scheme language
;; https://docs.gimp.org/2.10/en/gimp-using-script-fu-tutorial-first-script.html
(define (checker image drawable color-bg color-fg)
(let* ((width (car (gimp-image-width image)))
(height (car (gimp-image-height image)))
(width-str (number->string width))
(height-str (number->string height))
(message (string-append "Image size: " width-str "x" height-str "px"))
(x 0)
(y 0))
;; fill layer with background color (light gray)
(gimp-context-set-background color-bg)
(gimp-drawable-fill drawable BACKGROUND-FILL)
;; draw checker
(while (< y height)
(set! x (if (even? y) 0 1))
(while (< x width)
(gimp-drawable-set-pixel drawable x y 3 (list->vector color-fg))
(set! x (+ x 2)))
(set! y (+ y 1)))
(gimp-displays-flush)))
(script-fu-register
"checker" ;function name
"Checker" ;menu label
"Draws a checker." ;description
"Hakim Benoudjit" ;author
"Copyright 2026, Hakim Benoudjit" ;copyright notice
"February 2026" ;date created
"RGB" ;image type that the script works on
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR "Background-color" '(0 0 #xff)
SF-COLOR "Foreground-color" '(#xff 0 0)
)
(script-fu-menu-register "checker" "<Image>/Filters/Hakim's")

Installation

$ sudo apt install guile-3.0

Help

From the command line:

$ sudo apt install guile-3.0-doc
$ info --vi-keys guile  # to use vim keybindings in info
  • h: Show shortcuts.
  • [ and ]: Go to the previous/next node.
  • g and G: Go to the start/end of the document.
  • Tab: Jump to hyperlinks (in order).
  • Alt-g and ': Follow the hyperlink, and return to where we were.
  • j and k: Scroll one line down/up.
  • u and d: Scroll half a page up/down.
  • /<text>: Search for occurrences of text.
  • n and N: Jump to the next/previous occurrence.

Gimp script-fu

  • Run TinyScheme from terminal: gimp-console -b -.
  • PDB (Procedure Database): internal registry of all Gimp functions that can be called.
  • E.g.: (gimp-image-scale image new-width new-height)
  • Image: While gimp image (canvas, layers...).
  • Drawable: Usually one layer (active one).
  • Browse plugins:
$ apt-get source gimp
$ cd <gimp>/plug-ins/script-fu
  • Scripts are installed in ~/.config/GIMP/2.10/scripts/.
  • Functions (script-fu ...): for registering plugins.

Script-fu functions

All of these functions return a list not a number:

  • gimp-image-list
  • gimp-image-width
  • gimp-image-height

The following function are used to change the background:

  • gimp-context-set-background: set the background color.
  • gimp-drawable-fill: fill active drawable (active layer) using foreground/background color.
  • gimp-displays-flush: modification won't be visible without flushing them to UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment