ブラシ保存スクリプト(Save All Layers as Brushes)で保存されるブラシ名の連番部分をゼロでパディングするように修正。
; Save All Layers as Brushes rel 0.02.1 | |
; Created by Graechan | |
; Comments directed to http://gimpchat.com or http://gimpscripts.com | |
; | |
; License: GPLv3 | |
; This program is free software: you can redistribute it and/or modify | |
; it under the terms of the GNU General Public License as published by | |
; the Free Software Foundation, either version 3 of the License, or | |
; (at your option) any later version. | |
; | |
; This program is distributed in the hope that it will be useful, | |
; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
; GNU General Public License for more details. | |
; | |
; To view a copy of the GNU General Public License | |
; visit: http://www.gnu.org/licenses/gpl.html | |
; | |
; | |
; ------------ | |
;| Change Log | | |
; ------------ | |
; Rel 0.01 - Initial Release | |
; Rel 0.02 - Added convert to GrayScale option | |
; Rel 0.02.1 - Added zero padding to name (by mieki256) | |
; | |
(define (script-fu-save-all-layers-as-brushes image drawable | |
name | |
folder | |
gray) | |
(let* ( | |
(dup-img (car (gimp-image-duplicate image))) ;create a duplicate image | |
(type (car (gimp-image-base-type dup-img))) | |
(layerList 0) | |
(layerId 0) | |
(cnt 1) | |
(layercnt 0) | |
(digits 4) | |
(str "") | |
(strd "") | |
) | |
(if (and (= gray TRUE) (not (= type 1))) (gimp-image-convert-grayscale dup-img)) ;convert the duplicated image to grayscale | |
(set! layerList (vector->list (cadr (gimp-image-get-layers dup-img)))) ;------create a layer list from the duplicated image | |
(set! layercnt (car (gimp-image-get-layers dup-img))) | |
(set! digits (if (< layercnt 10) 1 | |
(if (< layercnt 100) 2 | |
(if (< layercnt 1000) 3 4)))) | |
;;;;save each layer of the duplicated image as a brush | |
(while (not (null? layerList)) | |
(set! layerId (car layerList)) | |
(set! str (string-append "0000" (number->string cnt))) | |
(set! strd (substring str (- (string-length str) digits) (string-length str))) | |
(file-gbr-save RUN-NONINTERACTIVE | |
dup-img | |
layerId | |
(string-append folder DIR-SEPARATOR name "-" strd ".gbr") ;filename | |
(string-append folder DIR-SEPARATOR name "-" strd ".gbr") ;raw-filename | |
100 ;spacing | |
(string-append name " " strd)) ;description | |
(set! cnt (+ cnt 1)) | |
(set! layerList (cdr layerList)) | |
) ;endwhile | |
(gimp-brushes-refresh) ;----------------------------refresh the brushes | |
(gimp-image-delete dup-img) ;------------------------delete the duplicated image | |
) | |
) | |
(script-fu-register "script-fu-save-all-layers-as-brushes" | |
"レイヤーをブラシとして保存..." | |
"すべてのレイヤーをブラシ(.gbr)として保存します。" | |
"Graechan" | |
"Graechan - http://gimpchat.com" | |
"2013" | |
"RGB* GRAY* INDEXED*" | |
SF-IMAGE "image" 0 | |
SF-DRAWABLE "drawable" 0 | |
SF-STRING "ブラシ名" "My Brush" | |
SF-DIRNAME "保存フォルダ" (string-append gimp-directory "/brushes/") | |
SF-TOGGLE "グレースケールに変換" FALSE | |
) | |
(script-fu-menu-register "script-fu-save-all-layers-as-brushes" "<Image>/File") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
オリジナル版の入手先。
GIMPでPhotoshopのブラシを使おう