GiMP(方案)脚本错误 "illegal function"
GiMP (Scheme) Script-fu error "illegal function"
我正忙着做一个 Script-fu 并不断得到 "Error ( : 1) illegal function"。我不是 Scheme/Lisp 专家,只是想自动执行一些摄影任务。文档很少——要么 GiMP 只写了他们自己的内部操作,但没有写 Script-fu 中 Scheme 的语法,要么我发现 "tips" for GiMP v1.0(即过时了,它们没用)。
我查看了 GiMP 提供的一堆脚本,试图了解更多信息并解决这个问题,但无济于事。我在这里寻求帮助以消除错误,not 缩进布局或 Python-fu 存在的事实等
然后,代码(简化为功能框架):
;;
;; license, author, blah blah
;; FOR ILLUSTRATION PURPOSES
;; GiMP 2.8 LinuxMint 18.1
;; does the work, but then blows up saying "Error ( : 1) illegal function"
;;
(define (script-fu-ScriptFails InImage InLayer pickd mrge)
(let* (
(CopyLayer (car (gimp-layer-copy InLayer TRUE)) )
)
(gimp-image-undo-group-start InImage)
(gimp-image-add-layer InImage CopyLayer -1)
(gimp-drawable-set-visible CopyLayer TRUE)
;; Perform CHOSEN action on CopyLayer
(if (equal? pickd 0) ( ;; keep just the RED
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 1.0 0 0 0 0 0 0 0 0)
(gimp-drawable-set-name CopyLayer "RED")
))
(if (equal? pickd 1) ( ;; keep just the GREEN
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 1.0 0 0 0 0)
(gimp-drawable-set-name CopyLayer "GRN")
))
(if (equal? pickd 2) ( ;; keep just the BLUE
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU")
))
(if (equal? mrge #t) ( ;; to merge or not to merge
(gimp-layers-flatten InImage)
))
(gimp-image-undo-group-end InImage)
(gimp-display-flush)
)
)
(script-fu-register "script-fu-ScriptFails"
_"<Image>/Script-Fu/ScriptFails..."
"Runs but fails at the end. Why? Please help!"
"JK"
"(pop-zip,G-N-U)"
"2016.12"
"RGB*"
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Layer" 0
;; other variables:
SF-OPTION "Effect" '("R_ed" "G_rn" "B_lu")
SF-TOGGLE "Merge Layers" FALSE
)
您似乎使用括号作为块。例如:
(if (equal? pickd 2) ( ;; keep just the BLUE
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU")
))
你看到关于保持蓝色的评论之前的左括号了吗?那么这意味着你正在这样做:
((plu-in....) (gimp-drawable...))
第一个当然需要 return 一个函数才能成为有效的 Scheme,而第二个的 return 将作为提供的参数。如果你想做两个表达式因为它们的副作用那么你应该使用一个块。就像 C 方言块中的卷曲是 Scheme 中以 begin
开头的形式:
(begin
(plu-in....)
(gimp-drawable...))
因此这将计算表达式,如果最后一个表达式的结果也是函数的尾部,那么它就是结果。
另外,对于只有结果且没有其他选择的 if
,使用 when
会给你一个开始:
(when (equal? pickd 2) ;; keep just the BLUE (and no extra parens)
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU"))
我正忙着做一个 Script-fu 并不断得到 "Error ( : 1) illegal function"。我不是 Scheme/Lisp 专家,只是想自动执行一些摄影任务。文档很少——要么 GiMP 只写了他们自己的内部操作,但没有写 Script-fu 中 Scheme 的语法,要么我发现 "tips" for GiMP v1.0(即过时了,它们没用)。
我查看了 GiMP 提供的一堆脚本,试图了解更多信息并解决这个问题,但无济于事。我在这里寻求帮助以消除错误,not 缩进布局或 Python-fu 存在的事实等
然后,代码(简化为功能框架):
;;
;; license, author, blah blah
;; FOR ILLUSTRATION PURPOSES
;; GiMP 2.8 LinuxMint 18.1
;; does the work, but then blows up saying "Error ( : 1) illegal function"
;;
(define (script-fu-ScriptFails InImage InLayer pickd mrge)
(let* (
(CopyLayer (car (gimp-layer-copy InLayer TRUE)) )
)
(gimp-image-undo-group-start InImage)
(gimp-image-add-layer InImage CopyLayer -1)
(gimp-drawable-set-visible CopyLayer TRUE)
;; Perform CHOSEN action on CopyLayer
(if (equal? pickd 0) ( ;; keep just the RED
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 1.0 0 0 0 0 0 0 0 0)
(gimp-drawable-set-name CopyLayer "RED")
))
(if (equal? pickd 1) ( ;; keep just the GREEN
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 1.0 0 0 0 0)
(gimp-drawable-set-name CopyLayer "GRN")
))
(if (equal? pickd 2) ( ;; keep just the BLUE
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU")
))
(if (equal? mrge #t) ( ;; to merge or not to merge
(gimp-layers-flatten InImage)
))
(gimp-image-undo-group-end InImage)
(gimp-display-flush)
)
)
(script-fu-register "script-fu-ScriptFails"
_"<Image>/Script-Fu/ScriptFails..."
"Runs but fails at the end. Why? Please help!"
"JK"
"(pop-zip,G-N-U)"
"2016.12"
"RGB*"
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Layer" 0
;; other variables:
SF-OPTION "Effect" '("R_ed" "G_rn" "B_lu")
SF-TOGGLE "Merge Layers" FALSE
)
您似乎使用括号作为块。例如:
(if (equal? pickd 2) ( ;; keep just the BLUE
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU")
))
你看到关于保持蓝色的评论之前的左括号了吗?那么这意味着你正在这样做:
((plu-in....) (gimp-drawable...))
第一个当然需要 return 一个函数才能成为有效的 Scheme,而第二个的 return 将作为提供的参数。如果你想做两个表达式因为它们的副作用那么你应该使用一个块。就像 C 方言块中的卷曲是 Scheme 中以 begin
开头的形式:
(begin
(plu-in....)
(gimp-drawable...))
因此这将计算表达式,如果最后一个表达式的结果也是函数的尾部,那么它就是结果。
另外,对于只有结果且没有其他选择的 if
,使用 when
会给你一个开始:
(when (equal? pickd 2) ;; keep just the BLUE (and no extra parens)
(plug-in-colors-channel-mixer TRUE InImage CopyLayer FALSE 0 0 0 0 0 0 0 0 1.0)
(gimp-drawable-set-name CopyLayer "BLU"))