【问题标题】:script-fu invalid number of argumentsscript-fu 参数个数无效
【发布时间】:2014-08-04 00:20:15
【问题描述】:

我想创建一个像笔记本纸一样的图像, 我认为如果画线的部分很容易 是自动化的。

为了实现它,我决定使用 gimp 的函数命名 'gimp-rect-select' 并指定小的高度值。

我用谷歌搜索并写了一个方案文件, 但是当我从 gimp 的 Script-Fu 菜单中运行它时, gimp 向我展示了如下信息。

Error while executing FU01-multi-rect-select:

Error: ( : 1) 

Invalid number of arguments for gimp-rect-select 
(expected 8 but received 9) 

我想让你看看我的第一个脚本 指出哪里出了问题。

对我来说,我的自定义函数是这样定义的 它有 8 个参数,而不是 9 个。 以下是我的代码

    (define (FU01-multi-rect-select 
    image 
    drawable 
    x1 
    y1 
    w 
    h 
    p-offset 
    p-repeat
    )
    ;definition of variables
    (let* 
      (
        (X nil) 
        (Y nil) 
        (width nil) 
        (height nil) 
        (offset nil) 
        (repeat nil) 
        ;are they below necessary?
        (theLayer nil)
        (theImage nil)
      )
      ;(gimp-context-push ) 
      (gimp-image-undo-group-start image)
        
      ;(set! X (string->number x1))
      ;(set! Y (string->number y1))
      ;(set! width (string->number w))
      ;(set! height (string->number h))
      ;(set! offset (string->number p-offset))
      ;(set! repeat (string->number p-repeat))
        
      (set! X x1)
      (set! Y y1)
      (set! width w)
      (set! height h)
      (set! offset p-offset)
      (set! repeat p-repeat)

      (gimp-image-set-active-layer image drawable)
            
      (set! theLayer
        (car (gimp-image-get-active-layer image) )
      )
        
      ; select rectangle and after that, 
      ; add it to current selection
      ; multiple times that is specified with 'repeat'
      (while (> repeat 0)
        (gimp-rect-select image X Y width height 
                             CHANNEL-OP-ADD FALSE 0 0)
        (set! Y (+ Y height offset))
        (set! repeat (- repeat 1))
      )
        
      (gimp-image-undo-group-end image)
    ) ; end of let sentences

  )

    (script-fu-register "FU01-multi-rect-select" 
    "<Image>/Script-Fu/Select/multi rect select" 
    "add a rect selection to current selection multiple times\
    each time a rect is selected it is moved\
     in y axis by the value of offset" 
    "Masaaki Fujioka" 
    "copy right 2014 Masaaki Fujioka" 
    "August 3 2014" 
    "*" 
    SF-IMAGE    "SF-IMAGE"      0  
    SF-DRAWABLE "SF-DRAWABLE"   0   
    SF-VALUE    "start x"       "0" 
    SF-VALUE    "start y"       "0" 
    SF-VALUE    "width"         "0" 
    SF-VALUE    "height"        "0" 
    SF-VALUE    "offset"        "0" 
    SF-VALUE    "repeat"        "0" 

    )

【问题讨论】:

    标签: gimp script-fu gimpfu


    【解决方案1】:

    就像错误消息说的那样,gimp-rect-select 调用有一个额外的参数——如果你在过程浏览器上检查调用的规范,在“mode”参数之后应该有一个布尔值来告诉是否要使用羽化,另一个数字来告诉羽化量。您传递的是两个整数,而不是只需要一个数字。

    另外,请注意这个调用被标记为“已弃用”——这意味着虽然它在 gimp-2.8 中仍然有效,但由于一系列原因,你应该调用 gimp-image-select-rectangle 而不是这个。 (请注意,该调用的参数不同)。

    【讨论】:

    • 我误会了9的数字来自FU01-multi-rect-select。
    • 我会尝试解决这个问题,无论如何感谢您的即时回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多