Popular Posts

Saturday, April 9, 2011

Cartoon Effect: Photo effect using the Gimp.

Cartoon Effect:

This will turn a photo into a cartoon effect:

Here is the code -->

; Cartoon script for GIMP 2.x
(define (script-fu-cartoon
    (gimp-undo-push-group-start img)
    (gimp-levels-stretch drawable)
     (let*    (
            (width (car (gimp-drawable-width drawable)))
            (height (car (gimp-drawable-height drawable)))
            (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)))
            (TEMP6 (car (gimp-layer-new-from-drawable drawable img)))
            (TEMP7 (car (gimp-layer-new-from-drawable drawable img)))
            (TEMP8 (car (gimp-layer-new-from-drawable drawable img)))
        (gimp-image-add-layer img TEMP1 -1)
        (gimp-image-add-layer img TEMP2 -1)
        (plug-in-despeckle RUN-NONINTERACTIVE img TEMP1 (* width .003) 1 -1 256)
        (plug-in-sel-gauss RUN-NONINTERACTIVE img TEMP1 (* width .003) 13)
        (gimp-edit-copy TEMP1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP2 0)))
        (plug-in-gauss RUN-NONINTERACTIVE img TEMP2 (* width .007) (* height .007) 1)
        (gimp-layer-set-mode TEMP2 DIVIDE-MODE)
        (gimp-image-merge-down img TEMP2 0)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-desaturate-full TEMP1 DESATURATE-AVERAGE)
        (gimp-image-add-layer img TEMP3 -1)
        (gimp-image-add-layer img TEMP4 -1)
        (gimp-layer-set-mode TEMP3 MULTIPLY-MODE)
        (gimp-layer-set-mode TEMP4 MULTIPLY-MODE)
        (gimp-edit-copy TEMP1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP3 0)))
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP4 0)))
        (gimp-image-merge-down img TEMP3 0)
        (gimp-image-merge-down img TEMP4 0)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-threshold TEMP1 228 255)
        (gimp-image-add-layer img2 TONES -1)
        (gimp-desaturate-full TONES DESATURATE-LIGHTNESS)
        (gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 4 FALSE FALSE "0")
        (gimp-edit-copy TONES)
        (gimp-image-add-layer img TEMP6 +1)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP6 0)))
        (gimp-layer-set-mode TEMP1 OVERLAY-MODE)
        (gimp-image-merge-down img TEMP1 0)
        (gimp-image-add-layer img TEMP7 -1)
        (gimp-layer-set-mode TEMP7 COLOR-MODE)
        (gimp-layer-set-opacity TEMP7 77.0)
        (gimp-image-merge-down img TEMP7 0)
        (gimp-image-add-layer img TEMP8 -1)
        (gimp-layer-set-mode TEMP8 SATURATION-MODE)
        (gimp-layer-set-opacity TEMP8 67.0)
        (gimp-image-merge-down img TEMP8 0)
        (set! TEMP1 (car (gimp-image-get-active-layer img)))
        (gimp-layer-set-name TEMP1 "Cartoon")
        (gimp-undo-push-group-end img)
        (gimp-image-delete img2)
 "Creates a Cartoon Effect."
 SF-IMAGE    "Image"        0
 SF-DRAWABLE    "Drawable"    0



  1. Buenas ¡Good!
    I liked the cartoon effect

    Estaba buscando algo así !!!
    I was looking for somethig comics... and here was...

    (Discúlpame mi inglés)
    Gran saludo.

    I will this post in Twitter too...

  2. Thanks for these GIMP effects! I love them!