This will turn a photo into a Color Chalk effect:
Here is the code -->
;***************************************************************************************
; Color Chalk script for GIMP 2.x
;***************************************************************************************
(define (script-fu-color-chalk
img
drawable
)
(gimp-undo-push-group-start img)
(define (get-matrix matrix-list)
(define (list-ref l n) (nth n l))
(let* ((count 0)
(matrix (cons-array 25 'double)))
(while (< count 25)
(aset matrix count (list-ref matrix-list count))
(set! count (+ count 1)))
matrix))
(define (get-channels)
(let* ((channels (cons-array 5 'long)))
(aset channels 0 0)
(aset channels 1 1)
(aset channels 2 1)
(aset channels 3 1)
(aset channels 4 0)
channels))
(define matrix-list
(list 0 0 0 0 0
0 0 1 0 0
0 1 -5 1 0
0 0 1 0 0
0 0 0 0 0))
(let* (
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
(img2 (car (gimp-image-new width height 0)))
(layer-temp2 (car (gimp-layer-new-from-drawable drawable img2)))
(lineLayer (car (gimp-layer-copy drawable -1)))
(sketchLayer1 (car (gimp-layer-copy drawable -1)))
(sketchLayer2 (car (gimp-layer-copy drawable -1)))
(blackLayer (car (gimp-layer-new img width height 0 "blackLayer" 25 3)))
(grayLayer (car (gimp-layer-new img width height 0 "grayLayer" 100 3)))
(colorLayer (car (gimp-layer-copy drawable -1)))
(satLayer (car (gimp-layer-copy drawable -1)))
(liteLayer (car (gimp-layer-copy drawable -1)))
(matrix (get-matrix matrix-list))
(channels (get-channels))
)
(gimp-image-add-layer img lineLayer -1)
(gimp-image-add-layer img sketchLayer1 -1)
(gimp-image-add-layer img sketchLayer2 -1)
(plug-in-sel-gauss RUN-NONINTERACTIVE img sketchLayer2 (* width .005) 13)
(gimp-edit-copy sketchLayer2)
(gimp-floating-sel-anchor (car (gimp-edit-paste sketchLayer1 0)))
(plug-in-gauss RUN-NONINTERACTIVE img sketchLayer2 (* width .013) (* height .013) 1)
(gimp-layer-set-mode sketchLayer2 DIVIDE-MODE)
(gimp-image-merge-down img sketchLayer2 0)
(set! sketchLayer1 (car (gimp-image-get-active-layer img)))
(plug-in-cartoon RUN-NONINTERACTIVE img sketchLayer1 (* width .010) .20)
(gimp-layer-set-mode sketchLayer1 MULTIPLY-MODE)
(gimp-desaturate-full sketchLayer1 1)
(plug-in-gauss RUN-NONINTERACTIVE img sketchLayer1 (* width .005) (* width .005) 1)
(gimp-desaturate-full lineLayer 1)
(plug-in-convmatrix RUN-NONINTERACTIVE img lineLayer 25 matrix FALSE 1 128 5 channels 0)
(gimp-invert lineLayer)
(gimp-image-merge-down img sketchLayer1 0)
(set! drawable (car (gimp-image-get-active-layer img)))
(gimp-levels drawable HISTOGRAM-VALUE 128 255 3.0 0 255)
(gimp-image-add-layer img grayLayer -1)
(gimp-context-set-foreground '(176 176 176))
(gimp-drawable-fill grayLayer 0)
(gimp-image-add-layer img blackLayer -1)
(gimp-layer-add-alpha blackLayer)
(gimp-image-add-layer img colorLayer -1)
(gimp-layer-set-mode colorLayer COLOR-MODE)
(gimp-by-color-select colorLayer '(0 0 0) 10.4 0 0 0 0 0)
(gimp-selection-invert img)
(gimp-edit-clear blackLayer)
(gimp-selection-clear img)
(gimp-image-add-layer img satLayer -1)
(gimp-layer-set-mode satLayer SATURATION-MODE)
(gimp-layer-set-opacity colorLayer 66.0)
(gimp-layer-set-opacity satLayer 61.0)
(plug-in-gauss RUN-NONINTERACTIVE img colorLayer (* width .003) (* height .003) 1)
(plug-in-gauss RUN-NONINTERACTIVE img satLayer (* width .020) (* height .020) 1)
(gimp-image-add-layer img liteLayer -1)
(gimp-image-add-layer img2 layer-temp2 -1)
(gimp-image-convert-indexed img2 NO-DITHER MONO-PALETTE 2 FALSE FALSE "0")
(gimp-edit-copy layer-temp2)
(gimp-floating-sel-anchor (car (gimp-edit-paste liteLayer 0)))
(gimp-layer-set-mode liteLayer OVERLAY-MODE)
(gimp-layer-set-opacity liteLayer 30.0)
(plug-in-gauss RUN-NONINTERACTIVE img liteLayer (* width .017) (* height .017) 1)
(gimp-image-merge-down img grayLayer 0)
(gimp-image-merge-down img blackLayer 0)
(gimp-image-merge-down img colorLayer 0)
(gimp-image-merge-down img satLayer 0)
(gimp-image-merge-down img liteLayer 0)
(set! lineLayer (car (gimp-image-get-active-layer img)))
(gimp-edit-copy lineLayer)
(gimp-image-convert-rgb img2)
(gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp2 0)))
(gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 34 FALSE FALSE "0")
(gimp-edit-copy layer-temp2)
(gimp-floating-sel-anchor (car (gimp-edit-paste lineLayer 0)))
(gimp-image-delete img2)
(gimp-layer-set-name lineLayer "Color Chalk")
(gimp-undo-push-group-end img)
(gimp-displays-flush)
)
)
(script-fu-register
"script-fu-color-chalk"
_"<Image>/Script-Fu/Artistic/ColorChalk"
"Creates a Color Chalk style"
""
""
"2011"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
Color Chalk |
No comments:
Post a Comment