我正在编写我的第一个脚本,方案对我来说仍然不是很清楚。
我的脚本工作正常,但我想添加一个其他参数(仅可见),我有一行在某个地方导致非法函数错误,但在其他地方没有。
感谢您的帮助 :-)
这是我的台词:
(display " onlyvisible: ")(display onlyvisible)(newline)
这是我的代码:
(define (pitibalrog-test img filename onlyvisible)
(let*
(
(imgcopy (car ( gimp-image-duplicate img))) ; Copy to avoid changes on the original image
)
(display " onlyvisible: ")(display onlyvisible)(newline)
(pitibalrog-export-layers imgcopy (gimp-image-get-layers imgcopy) filename onlyvisible)
)
)
(define (pitibalrog-export-layers img listlayers filename onlyvisible)
(let*
(
(nblayers (car listlayers))
(layers (cadr listlayers))
(display "EXPORT LAYERS: LAYERS = ")(display layers)(newline)
(display " onlyvisible: ")(display onlyvisible)(newline) ; <--- HERE IT WORKS
(index 0)
(basename (unbreakupstr (butlast (strbreakup filename ".")) "."))
(extension (car (last (strbreakup filename "."))))
(layer)
)
(display " onlyvisible: ")(display onlyvisible)(newline) ; <--- HERE IS THE PROBLEM
(while (< index nblayers)
(set! layer (aref layers index))
(gimp-item-set-visible layer FALSE)
(set! index (+ index 1))
)
(set! index 0)
(while (< index nblayers)
(set! layer (aref layers index))
(set! filename (string-append basename (car(gimp-drawable-get-name layer)) "." extension))
(pitibalrog-export-layer img layer filename onlyvisible)
(set! index (+ index 1))
)
)
)
(define (pitibalrog-export-layer img layer filename onlyvisible)
(display " - export layer: ")(display layer)(newline)
(gimp-item-set-visible layer TRUE)
; LAYER GROUP
(when (= (car(gimp-item-is-group layer)) 1)
(display "Layer ")(display layer)(display " is a group")(newline)
(pitibalrog-export-layers img (gimp-item-get-children layer) filename onlyvisible)
)
; REAL LAYER
(when (= (car(gimp-item-is-group layer)) 0)
(display "Layer ")(display layer)(display " is not a group")(newline)
; (gimp-file-save RUN-NONINTERACTIVE img layer filename filename) ; NO MASK HANDLING!!!
(gimp-file-save RUN-WITH-LAST-VALS img layer filename filename)
)
(gimp-item-set-visible layer FALSE)
)
(script-fu-register "pitibalrog-test"
"<Image>/Script-Fu/Utils/pitibalrog-test..."
"Export all layers of the image in separete files" ;comment
"pitiBalrog" ;author
"pitiBalrog" ;copyright
"November 2012" ;date
"*A"
SF-IMAGE "img" 0
SF-FILENAME "destination" ""
SF-TOGGLE "Export only visible layers" TRUE
)