SQLの窓

2017年02月02日

PaintsChainer 用、線画作成 GIMP(Script-Fu)スクリプト

PaintsChainer

FU_sketch_pencil-sketch-BW.scm が元になっています。オリジナルは、パターンファイルを使ってさらに加工するのですが、その部分を省いて線画だけを表示するようにしています。出来上がったレイヤーは複数ありますが、線画のみを表示状態にしています。





; FU_sketch_pencil-sketch-BW.scm
; version 1.0 [gimphelp.org]
; last modified/tested by Paul Sherman
; 02/17/2014 on GIMP-2.8.10
;
;==============================================================
;
; Installation:
; This script should be placed in the user or system-wide script folder.
;
;	Windows Vista/7/8)
;	C:\Program Files\GIMP 2\share\gimp\2.0\scripts
;	or
;	C:\Users\YOUR-NAME\.gimp-2.8\scripts
;	
;	Windows XP
;	C:\Program Files\GIMP 2\share\gimp\2.0\scripts
;	or
;	C:\Documents and Settings\yourname\.gimp-2.8\scripts   
;
;	Linux
;	/home/yourname/.gimp-2.8/scripts  
;	or
;	Linux system-wide
;	/usr/share/gimp/2.0/scripts
;
;
;==============================================================
;
; LICENSE
;
;    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.
;
;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
;
;==============================================================
; Original information 
; 
; based on....
; pencil-sketch.scm
; Jeff Trefftzs <trefftzs@tcsn.net>
;
; but with a custom pattern and very specific, altered settings
;==============================================================


(define (FU-pencil-sketch-BW 
		inImage 
		inLayer
		inMerge
	)
	
	(gimp-image-undo-group-start inImage)
	(define indexed (car (gimp-drawable-is-indexed inLayer)))
	(if (= indexed TRUE)(gimp-image-convert-rgb inImage))	
	
  (let*
      (
       (WhiteLayer (car (gimp-layer-copy inLayer TRUE)))
       (MaskedLayer (car (gimp-layer-copy inLayer TRUE)))
       (EdgeLayer (car (gimp-layer-copy inLayer TRUE)))
       (LayerMask (car (gimp-layer-create-mask MaskedLayer 0)))
       )
    
    (gimp-image-insert-layer inImage WhiteLayer 0 -1)
    (gimp-image-insert-layer inImage MaskedLayer 0 -1)
    (gimp-image-insert-layer inImage EdgeLayer 0 -1)

    (gimp-item-set-name WhiteLayer "Paper Layer")
    (gimp-item-set-name MaskedLayer "Copy with layer mask")
    (gimp-item-set-name EdgeLayer "Edges from original image")

    (gimp-drawable-set-visible WhiteLayer FALSE)
    (gimp-drawable-set-visible MaskedLayer FALSE)
    (gimp-drawable-set-visible LayerMask FALSE)
    (gimp-drawable-set-visible inLayer FALSE)

    ; Real work goes in here
    (gimp-drawable-fill WhiteLayer WHITE-FILL) ; Fill the white layer
	
    ; Create the layer mask and put the paper pattern in it.
;    (gimp-layer-add-mask MaskedLayer LayerMask)
;    (gimp-context-set-pattern "Pencil-Sketch")
;    (gimp-edit-bucket-fill LayerMask PATTERN-BUCKET-FILL NORMAL-MODE
;		      100		; opacity
;		      0			; threshold
;		      FALSE		; no sample-merged
;		      0 0)		; X, Y coords
;    (gimp-image-unset-active-channel inImage) ; finished with it
    
    ; Now find the edges
    (gimp-image-set-active-layer inImage EdgeLayer)

   (define tmplayer (car (gimp-layer-copy EdgeLayer TRUE)))

   (gimp-image-insert-layer inImage tmplayer 0 -1)
   (gimp-layer-set-mode tmplayer DIVIDE-MODE)
   (plug-in-gauss-iir TRUE inImage tmplayer 14 TRUE TRUE)
   (set! EdgeLayer 
	 (car (gimp-image-merge-down inImage tmplayer
					 EXPAND-AS-NECESSARY)))
   (gimp-levels EdgeLayer HISTOGRAM-VALUE
		210 ; low input
		255	; high input
		1.6	; gamma
		30 255)
	   
    (gimp-layer-set-mode EdgeLayer DARKEN-ONLY-MODE) ; in case white bg
	
	;(gimp-desaturate-full EdgeLayer DESATURATE-LUMINOSITY)
    (gimp-image-set-active-layer inImage inLayer)
    ); end let
	;(gimp-desaturate-full inLayer DESATURATE-LUMINOSITY)
	(if (= inMerge TRUE)(gimp-image-merge-visible-layers inImage EXPAND-AS-NECESSARY))
	(if (not (= GRAY (car (gimp-image-base-type inImage))))
		 (gimp-image-convert-grayscale inImage))
    (gimp-image-undo-group-end inImage)

    (gimp-displays-flush)


  )

(script-fu-register "FU-pencil-sketch-BW"
	"<Image>/Script-Fu/Sketch/Pencil Sketch BW"
	"Creates an black and white pencil sketch of an image."
	"Paul Sherman"
	"psherman2001@gmail.com"
	"Tuesday, 02/18/2014"
	"*"
	SF-IMAGE 		"The Image" 								0
	SF-DRAWABLE 	"The Layer" 								0
	SF-TOGGLE     	"Merge layers when complete?" 				FALSE
)




タグ:GIMP Script-Fu
posted by at 2017-02-02 09:56 | Comment(0) | GIMP スクリプト | このブログの読者になる | 更新情報をチェックする
SQLの窓全体の検索
Custom Search
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

※ブログオーナーが承認したコメントのみ表示されます。


Android SDK ポケットリファレンス
改訂版 Webデザイナーのための jQuery入門
今すぐ使えるかんたん ホームページ HTML&CSS入門
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX