; ; watercolor.scm - Yet another way to make artsy images from photos ; ; ;;; -------------------------------------------------------------------- ;;; version 0.1 by Jeff Trefftzs ;;; - Initial relase ;;; version 0.2 Raymond Ostertag ;;; - ported to Gimp 2.0, changed menu entry ;;; ;;; -------------------------------------------------------------------- ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ;; Changelog: Version 1.1 now places the displacement map in its own ;; channel, instead of as yet another layer; it allows blurring the ;; displacement map for a smoother effect, and allows blurring (smoothing) ;; of 0. ; Define the function: (define (script-fu-watercolor inImage inLayer inBlur inBright inXdisp inYdisp inStyle) (let* ( (newlayer (car (gimp-layer-copy inLayer TRUE))) (displacemap (car (gimp-channel-new inImage (car (gimp-image-width inImage)) (car (gimp-image-height inImage)) "Displacement Map" 50 '(202 202 0)))) ) (gimp-image-undo-group-start inImage) ;; Create a new layer and set it to divide mode. ;; Place it on top of the layer stack. (gimp-drawable-set-name newlayer "Divide Layer") (gimp-layer-set-mode newlayer DIVIDE-MODE) (gimp-image-add-layer inImage newlayer -1) ;; Copy the original image into a channel and blur it as requested. ;; This becomes the displacement map for bending the divide layer. ;; The channel is initially filled with black. (gimp-image-add-channel inImage displacemap -1) (gimp-drawable-fill displacemap WHITE-FILL) (gimp-invert displacemap) (gimp-drawable-set-visible displacemap FALSE) (gimp-edit-copy inLayer) (gimp-floating-sel-anchor (car (gimp-edit-paste displacemap TRUE))) ;; Now blur the displacement map channel. If blur radius is 0, then ;; skip this step. (if (> inBlur 0) (plug-in-gauss-iir TRUE inImage displacemap inBlur TRUE TRUE) ) ;; Displace the new layer using the displacement map we just created. ;; This bends the original as if seen through wavy glass. (plug-in-displace 1 inImage newlayer inXdisp inYdisp TRUE TRUE displacemap displacemap inStyle) ;; Since the new layer is in divide mode, the resulting image is ;; very pale. This step adjusts the brightness by tweaking the ;; image gamma using Image->Colors->Levels. The higher the gamma ;; of the new layer, the more saturated the colors appear. (gimp-levels newlayer HISTOGRAM-VALUE 0 255 inBright 0 255) (gimp-image-undo-group-end inImage) (gimp-image-set-active-layer inImage newlayer) (gimp-displays-flush) ) ) (script-fu-register "script-fu-watercolor" _"/Script-Fu/Alchemy/Watercolor..." "Gives a photo the effect of being a watercolor sketch. It uses an optionally blurred copy of the original image as a displacement map for a superior layer which is set to DIVIDE-MODE mode." "Jeff Trefftzs" "Copyright 2001, Jeff Trefftzs" "July 2, 2001" "RGB* GRAY* INDEXED*" SF-IMAGE "The Image" 0 SF-DRAWABLE "The Layer" 0 SF-ADJUSTMENT "Smoothing" '(20 0 1024 1 10 0 1) SF-ADJUSTMENT "Saturation (0 (lighter) <--> 4 (darker))" '(1.5 0 4 .01 .1 2 1) SF-ADJUSTMENT "X Displacement" '(20 -1024 1024 1 10 0 1) SF-ADJUSTMENT "Y Displacement" '(20 -1024 1024 1 10 0 1) SF-OPTION "Edge Behavior" '("Wrap" "Smear" "Black") )