~/.gimp-$ver/scripts
;; export psd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (script-fu-my-export-psd indir) (let* ((flist nil) (export-img nil) (export-drawable nil) (export-filename nil) (drawable-new nil) ) (set! flist (file-glob (string-append indir "\\*.xcf") 0 ; encoding:UTF-8 )) ; show file list (full phth) ;(gimp-message (number->string (car flist))) ;(gimp-message (car (car (cdr flist))) ) ;;(tracing TRUE) (for-each (lambda (file) (set! export-img (gimp-file-load 1 ; RUN-NONINTERACTIVE ; 0 ; RUN-INTERACTIVE file file)) ;; when export pdf ;; (gimp-image-merge-visible-layers (car export-img) ;; 0 ; EXPAND-AS-NECESSARY ;; ) (set! export-drawable (gimp-image-get-active-drawable (car export-img))) (set! export-filename (string-append (substring file 0 (- (string-length file) 4)) ".psd")) ;; (substring file 0 (- (string-length file) 4)) ".pdf")) (file-psd-save 1 ; RUN-NONINTERACTIVE (car export-img) (car export-drawable) export-filename export-filename 0 ; compression none 0 ; fill order: MSB to LSB ) ;; (file-pdf-save 1 ; RUN-NONINTERACTIVE ;; (car export-img) ;; (car export-drawable) ;; export-filename ;; export-filename ;; FALSE ; Convert bitmaps to ;; ; vector graphics ;; ; where possible. ;; TRUE ; ignore hidden ;; TRUE ; apply masks ;; ) (gimp-image-delete (car export-img))) (car (cdr flist))) ;;(tracing FALSE) )) ;; register ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (script-fu-register "script-fu-my-export-psd" _"<Image>/Script-Fu/misc/myExportPsd" "export psd" "kam" "kam" "4-26-2015" "" SF-DIRNAME "in dir" "" )
;; tonelayer.scm ;; script-fu-add-tone-layers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (script-fu-add-tone-layers img drawable) (let* ((width (car (gimp-image-width img))) (height (car (gimp-image-height img))) (layerNameList '("k10" "k20" "k30" "k40" "k100")) (cur-layer (car (gimp-image-get-active-layer img))) ) ;; undo point (gimp-image-undo-group-start img) ;; set master line mode (gimp-layer-set-mode cur-layer 3 ; multiply ) ;; background (gimp-image-insert-layer img (car (gimp-layer-new img width height 3 ; GRAYA "backGround" 100 ; opaq 0 ; combine normal )) (car (gimp-item-get-parent cur-layer)) 0 ; 0 or -1 ) (set! cur-layer (car (gimp-image-get-active-layer img))) (gimp-drawable-fill cur-layer 2 ; white fill ) (gimp-image-lower-item img cur-layer) ;; gray scale layers (while (not (null? layerNameList) ) (gimp-image-insert-layer img (car (gimp-layer-new img width height 3 ; GRAYA (car layerNameList) 100 ; opaq 0 ; combine normal )) (car (gimp-item-get-parent cur-layer)) 0 ; 0 or -1 ) (set! cur-layer (car (gimp-image-get-active-layer img))) (gimp-image-lower-item img cur-layer) (set! layerNameList (cdr layerNameList))) (gimp-image-undo-group-end img) )) ;; register ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (script-fu-register "script-fu-add-tone-layers" _"<Image>/Script-Fu/misc/addToneLayers" "add tone layer" "kam" "kam" "4-25-2015" "" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 )
;; convgif1.scm ;; 1. (バッチから)ファイルを開く ;; 2. トリミング(optional) ;; 3. 背景レイヤ追加 ;; 4. 解像度変更 ;; 5. アニメーションgifで保存 ;; (define (script-fu-resize-gif inSrcFile ;; inDstFile ;; inCropSw ;; トリミングするかどうか inBottomSize ;; トリミングするときの,[[下端]]からのサイズ inResizeHeight ;; リサイズするときのサイズ ) (tracing TRUE) (let* ( ;; ファイルオープン (theImg (car (gimp-file-load 0 inSrcFile inSrcFile))) ;; 描画領域取得 (theDrawable (car (gimp-image-active-drawable theImg))) ;; 元画像の高さ (theImgHeight (car (gimp-image-height theImg))) ;; 元画像の幅 (theImgWidth (car (gimp-image-width theImg))) ;; 下端サイズ (theBottomSize inBottomSize) ;; リサイズするときのサイズ (theResizeHeight inResizeHeight) (theResizeWidth) ) ;; logic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 画像の切り取り ;; TRUE or FALSEの評価は,"=" 関数を使うこと. ;; (if inCropSw ... とすると,inCropSwがTRUE でも FALSEでも ;; if が成立する. (if (= inCropSw TRUE) (begin (gimp-image-crop theImg ;; target image theImgWidth ;; new width theBottomSize ;; new height 0 ;; offx (- theImgHeight theBottomSize) ;; offy ) (gimp-message "resize inCropSw") ) (gimp-message "no resize") ) ;; (gimp-display-new theImg) ;; リサイズ後の幅計算 (if (= inCropSw TRUE) (set! theResizeWidth (* theImgWidth (/ inResizeHeight inBottomSize ))) (set! theResizeWidth (* theImgWidth (/ inResizeHeight theImgHeight )))) ;; リサイズ (gimp-image-scale-full theImg ;; target image theResizeWidth ;; new-Width theResizeHeight ;; new-Height INTERPOLATION-LINEAR ;; interpolation) ) ;; gifアニメーションで保存 (file-gif-save 1 ;; run-mode(interactive, non interactive) theImg ;; image to save theDrawable ;; drawable to save inDstFile ;; file name to save inDstFile ;; raw file name 0 ;; interlace 1 ;; loop infinity 200 ;; default delay 0 ;; (animated gif) Default disposal type ;; (0=`don't care`, 1=combine, 2=replace) ) ;; デバッグ表示 ;; (gimp-display-new theImg) ;; (gimp-quit TRUE) ) ) ;; regist script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (script-fu-register "script-fu-resize-gif" ; func name ; register point ; file/create以下に配置すると,画像を開いていない状態でも実行できる ; スクリプトになる. ; "<Toolbox>/Xtns/Script-Fu/"以下に配置すると, ; 画像を開いた状態でのみ有効なスクリプトとなる. "<Image>/File/Create/ResizeScript" ; "resize gif" ;description "author" ;author "copyright" ;copyright notice "Feb. 27, 2013" ;date created "RGB*, GRAY*, INDEXED*" ;image type that the script works on ;; 以下,引数.順番に渡される SF-STRING "SrcFile" "" ; example pattern: "z:/0.gif"w ; windowsでも,パスの区切り文字は"/". ; "\"だとエラーとなる. SF-STRING "DstFile" "" SF-TOGGLE "CropSw" TRUE SF-VALUE "BottomSize" "0" SF-VALUE "ResizeHeight" "300" )
gimp= "/cygdrive/c/programs/GIMP-2.0/bin/gimp-2.6.exe -i -b " template= "(script-fu-resize-gif \\\"z:/work/_filename_\\\" " + "\\\"z:/work/dst/_filename_\\\" FALSE 250 1200) " buf= ""; Dir::glob("*.gif").each{|f| # print(File.basename(f) + "\n"); buf= buf + template.gsub("_filename_", File.basename(f)); } command= gimp + "\"" + buf + " (gimp-quit TRUE)" + "\""; print(command + "\n"); `#{command}`; # オプションの意味は,以下の通り # -i 画面を出さない # -b 以下に続く文字列をscriptとして実行する. # 典型パターンは,以下の通り # $ gimp.exe -i -b "(funcname \"filename1\") (funcname \"filename2\") .. (gimp-quit TRUE)" # なお,以下のようにgimpコマンドを連続で叩くと,gimpプロセスが複数並行で # 立ち上がり,負荷が高くなる. # $ gimp.exe -i -b "(funcname \"filename1\") (gimp-quit TRUE)" # $ gimp.exe -i -b "(funcname \"filename2\") (gimp-quit TRUE)" # これは,gimp.exeがノンブロッキングで帰ってくるため. # 前者の,シーケンシャルに処理する方がおすすめ.
;author