Popular Posts

Saturday, April 9, 2011

Pencil Shade Effect: Photo effect using the Gimp.

Pencil Shade Effect:

This will turn a photo into a Pencil Shade effect:

Here is the code -->
;*************************************************************************************** 
; Pencil Shade script for GIMP 2.x
;***************************************************************************************
(define    (script-fu-pencil-shade
        image
        drawable
    )
    (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 matrix-list
        (list    16.0 -1.0 -1.0 -1.0 -1.0
            -1.0 16.0 -1.0 -1.0 -1.0
            -1.0 -1.0 16.0 -1.0 -1.0
            -1.0 -1.0 -1.0 16.0 -1.0
            -1.0 -1.0 -1.0 -1.0 16.0))
    (gimp-undo-push-group-start image)
    (let*    (
            (shadeLayer (car (gimp-layer-new-from-drawable drawable image)))
            (lineLayer (car (gimp-layer-new-from-drawable drawable image)))
            (matrix (get-matrix matrix-list))
            (channels (cons-array 5 'long))
            (aset channels 0 1)
            (aset channels 1 1)
            (aset channels 2 1)
            (aset channels 3 1)
            (aset channels 4 0)
        )
        (gimp-image-add-layer image shadeLayer -1)
        (gimp-image-add-layer image lineLayer -1)
        (gimp-layer-set-mode lineLayer MULTIPLY-MODE)
        (gimp-desaturate lineLayer)
        (gimp-desaturate shadeLayer)
        (plug-in-apply-canvas RUN-NONINTERACTIVE image shadeLayer 2 1)
        (plug-in-dog RUN-NONINTERACTIVE image shadeLayer 35 3 TRUE TRUE)
        (plug-in-convmatrix RUN-NONINTERACTIVE image shadeLayer 25 matrix FALSE 50 0 5 channels 2)
        (plug-in-sharpen RUN-NONINTERACTIVE image shadeLayer 45)
        (plug-in-convmatrix RUN-NONINTERACTIVE image shadeLayer 25 matrix FALSE 50 0 5 channels 2)
        (plug-in-sharpen RUN-NONINTERACTIVE image shadeLayer 85)
        (plug-in-dog RUN-NONINTERACTIVE image lineLayer 3 1 TRUE TRUE)
        (plug-in-unsharp-mask RUN-NONINTERACTIVE image lineLayer 4 4 5)
        (gimp-layer-set-opacity lineLayer 50)
        (gimp-image-merge-down image lineLayer 0)
        (set! shadeLayer (car (gimp-image-get-active-layer image)))
        (gimp-layer-set-name shadeLayer "Pencil-Shade")
        (gimp-undo-push-group-end image)
        (gimp-displays-flush)

    )
)

(script-fu-register
 "script-fu-pencil-shade"
 _"<Image>/Script-Fu/Artistic/Pencil-Shade"
 "Creates a pencil shaded style"
 ""
 ""
 "2011"
 "RGB* GRAY*"
 SF-IMAGE "Image" 0
 SF-DRAWABLE "Drawable" 0
)


Pencil Shade

No comments:

Post a Comment