Hi Jeff

On Monday 29 April 2002 17:51 pm, Jeff Trefftzs wrote:

> A suggestion:  Whenever possible, use the symbolic names rather than the
> absolute numbers for the modes (e.g., (gimp-layer-set-mode mylayer
> OVERLAY-MODE) instead of (gimp-layer-set-mode mylayer 5) ).

Aha! I didn't know there was a symbolic name, in fact I only guessed at the 
numeric value by counting the menu items in the mode menu.

> For the Mark II version, you might want to add a toggle to allow automatic
> flattening, and maybe a  SF_ADJUSTMENT to allow the user to set
> transparency when the script is called.
> (And maybe another adjustment to specify the blur radius?).

Ok I've incorporated these into the script. To be honest the blur radius is 
hardly worth changing from the default IMO, but the option is there. I made 
automatic flattening default to FALSE for safety's sake, and I've also 
included the undo functions for a little extra useability.

I've been manually applying this technique to my photographs for months, 
promising myself I would check out script-fu but never getting around to it. 
Wish I'd done this sooner - its so easy!
Thanks for making suggestions that made me learn a little more :-)

The Mark II version...

; contrast-mask.scm
; A gimp script to adjust contrast levels in photographs,
; reducing highlights and brightening shadows

(define (script-fu-contrast-mask img
        drawable opacity blurring flatten)

 ; Start the undo group
 (gimp-undo-push-group-start img)

 ; Create a new layer to hold the contrast mask
 (set! mylayer (car (gimp-layer-copy drawable 0)))

 ; Name the layer
 (gimp-layer-set-name mylayer "Contrast Mask")

 ; Add the layer to the image
 (gimp-image-add-layer img mylayer 0)

 ; Set the draw mode to overlay
 (gimp-layer-set-mode mylayer OVERLAY-MODE)

 ; Desaturate the layer
 (gimp-desaturate mylayer)

 ; Invert the colours
 (gimp-invert mylayer)

 ; Blur the layer 
 (plug-in-gauss-rle 1 img mylayer blurring 1 1)

 ; Set the opacity of the layer
 (gimp-layer-set-opacity mylayer opacity)

 ; Optionally flatten the image
 (if (= flatten TRUE) (gimp-image-flatten img))

 ; Handle undo
 (gimp-undo-push-group-end img)

 ; Flush the display


(script-fu-register "script-fu-contrast-mask"
"Create a mask in a new layer to improve contrast in photographs."
            "John Keniry"
            "John Keniry"
            "April, 2002"
            SF-IMAGE "Image" 0
            SF-DRAWABLE "Layer" 0
            SF-ADJUSTMENT "Mask opacity" '(100 0 100 1 20 0 0)
            SF-VALUE "Mask blurring" "94"
            SF-TOGGLE   "Flatten layers" FALSE

Gimp-user mailing list

Reply via email to