This will turn a photo into a Pencil Sketch effect:
Here is the code -->
;***************************************************************************************
; Pencil Sketch script for GIMP 2.x
;***************************************************************************************
(define (script-fu-PencilSketch
img
drawable
)
(gimp-undo-push-group-start img)
(let* (
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
(temp0 (car (gimp-layer-new-from-drawable drawable img)))
(temp1 (car (gimp-layer-new-from-drawable drawable img)))
(temp2 (car (gimp-layer-new-from-drawable drawable img)))
(temp3 (car (gimp-layer-new-from-drawable drawable img)))
(temp4 (car (gimp-layer-new-from-drawable drawable img)))
(temp5 (car (gimp-layer-new-from-drawable drawable img)))
(startx (/ width 10))
(starty (/ height 10))
(color-save (car (gimp-context-get-foreground)))
(vtemp0 (car (gimp-layer-new-from-drawable drawable img)))
(vtemp0-mask (car (gimp-layer-create-mask vtemp0 ADD-WHITE-MASK)))
)
(gimp-image-add-layer img temp1 -1)
(gimp-image-add-layer img temp2 -1)
(plug-in-gauss RUN-NONINTERACTIVE img temp2 (* width .013) (* height .013) 1)
(gimp-layer-set-mode temp2 DIVIDE-MODE)
(gimp-image-merge-down img temp2 0)
(set! temp1 (car (gimp-image-get-active-layer img)))
(plug-in-cartoon RUN-NONINTERACTIVE img temp1 (* width .013) .20)
(gimp-desaturate-full temp1 DESATURATE-AVERAGE)
(gimp-levels temp1 HISTOGRAM-VALUE 0 255 1.0 170 255)
(plug-in-sel-gauss RUN-NONINTERACTIVE img temp1 (* width .016) 13)
(gimp-image-add-layer img temp3 -1)
(gimp-desaturate-full temp3 DESATURATE-AVERAGE)
(gimp-levels temp3 HISTOGRAM-VALUE 153 169 .16 247 255)
(gimp-layer-set-mode temp3 MULTIPLY-MODE)
(plug-in-gauss RUN-NONINTERACTIVE img temp3 (* width .033) (* height .033) 1)
(gimp-image-merge-down img temp3 0)
(gimp-image-add-layer img temp0 -1)
(gimp-desaturate-full temp0 DESATURATE-AVERAGE)
(gimp-brightness-contrast temp0 91 111)
(gimp-layer-set-mode temp0 GRAIN-EXTRACT-MODE)
(gimp-layer-set-opacity temp0 7.1)
(gimp-image-merge-down img temp0 0)
(set! temp1 (car (gimp-image-get-active-layer img)))
(plug-in-gauss RUN-NONINTERACTIVE img temp1 (* width .003) (* height .003) 1)
(gimp-layer-set-mode temp1 MULTIPLY-MODE)
(gimp-image-add-layer img temp4 +1)
(gimp-desaturate-full temp4 DESATURATE-AVERAGE)
(gimp-image-add-layer img temp5 +1)
(gimp-desaturate-full temp5 DESATURATE-AVERAGE)
(gimp-invert temp5)
(plug-in-gauss 1 img temp5 (* width .09) (* height .09) 0)
(gimp-layer-set-mode temp5 ADDITION-MODE)
(gimp-image-merge-down img temp5 0)
(gimp-image-merge-down img temp1 0)
(gimp-image-add-layer img vtemp0 -1)
(gimp-ellipse-select img startx starty (* 0.8 width) (* 0.8 height) CHANNEL-OP-REPLACE TRUE FALSE 0.0)
(gimp-layer-add-mask vtemp0 vtemp0-mask)
(gimp-context-set-foreground '(0 0 0))
(gimp-drawable-fill vtemp0 WHITE-FILL)
(gimp-edit-bucket-fill vtemp0-mask FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
(gimp-selection-clear img)
(gimp-layer-set-mode vtemp0 HARDLIGHT-MODE)
(gimp-context-set-foreground color-save)
(plug-in-gauss RUN-NONINTERACTIVE img vtemp0-mask (* width .36) (* height .36) 1)
(gimp-layer-set-opacity vtemp0 78.0)
(gimp-image-merge-down img vtemp0 0)
(set! temp1 (car (gimp-image-get-active-layer img)))
(gimp-layer-set-name temp1 "Pencil Sketch")
(gimp-undo-push-group-end img)
(gimp-displays-flush)
)
)
(script-fu-register
"script-fu-PencilSketch"
_"<Image>/Script-Fu/Artistic/Pencil Sketch"
"Creates a Pencil Sketch Effect."
""
""
""
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
Pencil Sketch |
No comments:
Post a Comment