Popular Posts

Saturday, April 9, 2011

Comic Effect: Photo effect using the Gimp.

Comic Effect:

This will turn a photo into a comic effect:


Here is the code -->
;*************************************************************************************** 
; Comic script for GIMP 2.x
; --------------------------------------------------------------------
(define (script-fu-Comic
        img
        drawable
    )
    (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)))
            (COLOR (car (gimp-layer-new-from-drawable drawable img2)))
             (TEMP0 (car (gimp-layer-copy drawable FALSE)))
             (TEMP1 (car (gimp-layer-copy drawable FALSE)))
             (TEMP2 (car (gimp-layer-copy drawable FALSE)))
             (TEMP3 (car (gimp-layer-copy drawable FALSE)))
             (TEMP4 (car (gimp-layer-copy drawable FALSE)))
             (TEMP5 (car (gimp-layer-copy drawable FALSE)))
             (TEMP6 (car (gimp-layer-copy drawable FALSE)))
            (colorsave '(0 0 0))
        )
        (gimp-image-add-layer img TEMP0 -1)
        (gimp-image-add-layer img TEMP1 -1)
        (gimp-image-add-layer img TEMP2 -1)
        (gimp-image-add-layer img TEMP4 -1)
        (gimp-image-add-layer img TEMP3 -1) 
        (gimp-image-add-layer img TEMP5 -1)
        (set! colorsave (car (gimp-context-get-foreground)))
        (gimp-context-set-foreground '(177 177 177))
        (gimp-drawable-fill TEMP5 FOREGROUND-FILL)
        (gimp-layer-set-mode TEMP5 OVERLAY-MODE)
        (gimp-context-set-foreground colorsave)
        (gimp-desaturate-full TEMP3 DESATURATE-AVERAGE)
        (gimp-layer-set-mode TEMP3 DODGE-MODE)
        (gimp-desaturate-full TEMP4 DESATURATE-AVERAGE)
        (gimp-desaturate-full TEMP2 DESATURATE-AVERAGE)
        (plug-in-gauss RUN-NONINTERACTIVE img TEMP3 (* width .013) (* height .013) 0) ;IIR
        (gimp-invert TEMP3)
        (gimp-image-merge-down img TEMP3 EXPAND-AS-NECESSARY)
        (set! TEMP4 (car (gimp-image-get-active-layer img)))
        (gimp-layer-set-mode TEMP4 MULTIPLY-MODE)
        (gimp-threshold TEMP4 237 255)
        (gimp-threshold TEMP2 25 255)
        (gimp-layer-set-mode TEMP2 MULTIPLY-MODE)
        (gimp-layer-set-opacity TEMP2 60.0)
        (gimp-desaturate-full TEMP1 DESATURATE-AVERAGE)
        (gimp-layer-set-mode TEMP1 DIVIDE-MODE)
        (gimp-levels TEMP1 HISTOGRAM-VALUE 0 181 1.0 0 255)
        (gimp-image-merge-down img TEMP1 EXPAND-AS-NECESSARY)
        (set! TEMP0 (car (gimp-image-get-active-layer img)))
        (gimp-image-merge-down img TEMP2 EXPAND-AS-NECESSARY)
        (set! TEMP0 (car (gimp-image-get-active-layer img)))
        (gimp-image-merge-down img TEMP4 EXPAND-AS-NECESSARY)
        (set! TEMP0 (car (gimp-image-get-active-layer img)))
        (gimp-image-merge-down img TEMP5 EXPAND-AS-NECESSARY)
        (set! TEMP0 (car (gimp-image-get-active-layer img)))
        (gimp-layer-set-name TEMP0 "Comic")
        (gimp-image-add-layer img2 COLOR -1)
        (gimp-edit-copy TEMP0)
        (gimp-floating-sel-anchor (car (gimp-edit-paste COLOR 0)))
        (gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 34 FALSE FALSE "0")
        (gimp-edit-copy COLOR)
        (gimp-floating-sel-anchor (car (gimp-edit-paste TEMP0 0)))
        (gimp-image-add-layer img TEMP6 -1)
        (gimp-desaturate-full TEMP6 DESATURATE-AVERAGE)
        (gimp-brightness-contrast TEMP6 83 120)
        (gimp-layer-set-mode TEMP6 MULTIPLY-MODE)
        (gimp-layer-set-opacity TEMP6 60.0)
        (gimp-image-merge-down img TEMP6 0)
        (gimp-image-delete img2)
        (gimp-undo-push-group-end img)
        (gimp-displays-flush)
    )
)
(script-fu-register
 "script-fu-Comic"
 _"<Image>/Script-Fu/Artistic/Comic"
 "Creates a Comic Book Effect."
 ""
 ""
 "2011"
 "RGB*"
 SF-IMAGE    "Image"        0
 SF-DRAWABLE    "Drawable"    0
)

Comic

1 comment:

  1. How do I use this? Is there somewhere I have to put this code?

    ReplyDelete