schemegimpscript-fu

GIMP Script-Fu: "Error: <: argument 1 must be: number"


I'm having an issue with writing a GIMP Script that applies a drop shadow. So this is how the script looks when you pull it from the console:

(script-fu-drop-shadow run-mode image drawable value value value color value toggle)

And these are the values I've entered:

(script-fu-drop-shadow 1 image layer 0 0 3 '(115.9 200.9 245.1) 1 0)

When I try to run it, I get the following error:

Execution error for 'MUA Portrait Outline - Blue Glow':
Error: <: argument 1 must be: number

I think I'm not really understanding all the values that I need to enter.

  1. run-mode is straightforward, since it says to either use 1 or 0.
  2. Based on prior scripts I've tried, I'm pretty sure that I leave image as image since it's just for the current image.
  3. I'm not too sure what drawable is, but I read that drawables include layers, so I put layer. Not sure if that's accurate.
  4. The next 3 value variables are for the x offset, y offset, and blur radius. Straightforward.
  5. I'm not too sure if I'm entering color correctly as I've never actually used a script that asks for the color, but I think I did it correctly just based on some research I did online.
  6. The last value variable is also straightforward, as it's the opacity of the shadow.
  7. I have no clue what to set for toggle. It says it accepts INT32 for that, so I figured I would just put 0. I tried to do some online research, but I couldn't find anything

Any help would be greatly appreciated! I'm not well-versed in Script-fu. I've tried a few things here and there, but I don't know much formal stuff. Feel free to explain things as simply as possible :)


Solution

  • You have to find numbers of current image and current drawable (if you are working with multiple images, these don't have to be 1 and 3), then call it without run-mode:

    > (gimp-image-list) 
    (1 #(1)) <-- All images, current image is one number from vector #(1)
    
    > (gimp-image-get-active-drawable 1)
    (3) <-- Current drawable of current image
    
    > (script-fu-drop-shadow 1 3 0 0 20 '(255 0 0) 100 0)
    (#t)
    

    If you don't know meaning of some arguments, you can check Procedure Browser (Help → Procedure Browser)- toggle argument is Allow resizing and you can also use TRUE or FALSE as value, because they evaluate to 1 or 0 respectively.

    EDIT: If you want run this as .scm script, follow these steps:

    (define (script-fu-my-script image drawable)
        (script-fu-drop-shadow image drawable 0 0 20 '(255 0 0) 100 0))
    
    (script-fu-register "script-fu-my-script"
      _"Add _Drop _Shadow..."
      _"Add drop shadow"
      "Author's name"
      "Author's name"
      "12/9/21"
      "*"
      SF-IMAGE       "Input image" 0
      SF-DRAWABLE    "Input drawable" 0)
    
    (script-fu-menu-register "script-fu-my-script"
                             "<Image>/My_Scripts/Drop")