2
我此腳本是瘸子的.scm:爲什麼GIMP不能處理這個腳本?
;MIT license.
(define (script-fu-export-layers img drw path outnameformat)
; credit to Vijay Mathew on Stack Overflow for the expand keywords function
(let ((expand-keywords (lambda(format tokens)
(let loop ((slist (string->list string))
(in-replace-mode #f)
(result ""))
(if (not (null? slist))
(let ((c (car slist)))
(cond (in-replace-mode
(let ((token (car (cdr (assoc c tokens)))))
(loop (cdr slist) #f (string-append result token))))
((char=? C#\~)
(loop (cdr slist) #t result))
(else
(loop (cdr slist) #f (
string-append result (make-string 1 c))))))
result)))))
(for-each (lambda (layer)
(let* (
(name (expand-keywords outnameformat '(
(#\i (car(gimp-image-get-name img)))
(#\l (car(gimp-drawable-get-name layer))))))
(outpath (string-append path "/" name)))
(gimp-file-save RUN-NONINTERACTIVE img layer outpath name)
)) (vector->list(cadr (gimp-image-get-layers img)))))
)
(script-fu-register
"script-fu-export-layers"
"L_ayers"
"Export all layers as individual files."
"Stuart P. Bentley <[email protected]>"
"Copyright 2011 Stuart P. Bentley"
"June 28, 2011"
"*"
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Layer" 0
SF-DIRNAME "Output directory" ""
SF-STRING "Filename Format (~i = image name, ~l = layer name)"
"~i-~l.png"
)
(script-fu-menu-register "script-fu-export-layers" "<Image>/File/E_xport")
隨着在文件頂部的註釋,該腳本不會加載。刪除註釋時,GIMP在刷新腳本時出現錯誤:「加載C:\ Users \ Stuart.gimp-2.6 \ scripts \ export-layers.scm時出錯:錯誤:不匹配的圓括號:1」。我不知道那是怎麼一回事,因爲當我在鍵盤上運行它時,它解析得很好(它在腳本 - 註冊點處斷開)。
如果它在第一條評論中嘔吐,你有沒有嘗試';信用評論? –
@Alex K .: D'oh。這讓我走上了解決問題的正確軌道。 –
最終腳本在http://registry.gimp.org/node/25394的GIMP插件註冊表中列出。 –