Popular Posts

Saturday, April 9, 2011

Comic Toned Effect: Photo effect using the Gimp.

Comic Toned Effect:

This will turn a photo into a Comic Toned effect:

Here is the code -->
;*************************************************************************************** 
; Comic-Toned script for GIMP 2.x
;*************************************************************************************** 
(define (script-fu-ComicToned
        img
        drawable
    )
    (gimp-undo-push-group-start img)
    (let*    (
            (WIDTH (car (gimp-drawable-width drawable)))
            (HEIGHT (car (gimp-drawable-height drawable)))
            (COLOR-SAVE '(0 0 0))
            (img2 (car (gimp-image-new WIDTH HEIGHT 0)))
            (TONES (car (gimp-layer-new-from-drawable drawable img2)))
            (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)))
            (TEMP6 (car (gimp-layer-new-from-drawable drawable img)))
            (TEMP7 (car (gimp-layer-new-from-drawable drawable img)))
        ) 
        (gimp-image-add-layer img TEMP1 -1)
        (gimp-image-add-layer img TEMP2 -1)
        (gimp-image-add-layer img2 TONES -1)
        (gimp-desaturate-full TONES DESATURATE-AVERAGE)
        (plug-in-sel-gauss RUN-NONINTERACTIVE img TEMP1 (* WIDTH .005) 13)
        (gimp-edit-copy TEMP1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP2 0)))
        (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 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-desaturate-full TEMP1 DESATURATE-AVERAGE)
        (gimp-image-add-layer img TEMP3 -1)
        (gimp-edit-copy TEMP1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP3 0)))
        (gimp-threshold TEMP3 246 255)
        (plug-in-cartoon RUN-NONINTERACTIVE img TEMP3 (* WIDTH .007) .20)
        (gimp-layer-set-mode TEMP3 MULTIPLY-MODE)
        (gimp-levels TEMP1 HISTOGRAM-VALUE 234 255 10 0 255) 
        (gimp-image-merge-down img TEMP3 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-threshold TEMP1 128 255)
        (gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 3 FALSE FALSE "0")
        (gimp-edit-copy TONES)
        (gimp-image-add-layer img TEMP4 -1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP4 0)))
        (gimp-levels TEMP4 0 0 255 1.0 0 217) 
        (gimp-layer-set-mode TEMP4 GRAIN-MERGE-MODE)
        (gimp-image-merge-down img TEMP4 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-image-add-layer img TEMP5 -1)
        (set! COLOR-SAVE (car (gimp-context-get-foreground)))
        (gimp-context-set-foreground '(207 207 207))
        (gimp-drawable-fill TEMP5 FOREGROUND-FILL)
        (gimp-layer-set-mode TEMP5 MULTIPLY-MODE)
        (gimp-context-set-foreground COLOR-SAVE)
        (gimp-image-merge-down img TEMP5 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-image-add-layer img TEMP6 -1)
        (gimp-layer-set-mode TEMP6 COLOR-MODE)
        (gimp-layer-set-opacity TEMP6 74.0)
        (gimp-image-merge-down img TEMP6 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-image-add-layer img TEMP7 -1)
        (gimp-layer-set-opacity TEMP7 64.6)
        (gimp-layer-set-mode TEMP7 SATURATION-MODE)
        (gimp-image-merge-down img TEMP7 EXPAND-AS-NECESSARY)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-layer-set-name TEMP1 "Comic Toned")
        (gimp-image-delete img2)
        (gimp-undo-push-group-end img)
        (gimp-displays-flush)
    )
)
(script-fu-register
 "script-fu-ComicToned"
 _"<Image>/Script-Fu/Artistic/ComicToned"
 "Creates a Comic with tones Effect."
 ""
 ""
 "2011"
 "RGB*"
 SF-IMAGE    "Image"        0
 SF-DRAWABLE    "Drawable"    0
)


Comic Toned

No comments:

Post a Comment