Site map

spacer

Script-Fu example and downloads

Contrast mask example

Below is an example of one of the script-fu's we have on the site for download. In all cases the example below has ; comments above the actions (in green starting with a semicolon) to aid your understanding of how they work. The ; comments dont actually do anything, they are only there to help your understanding of the program. There are also undo stages added for each part of the program, so that when you run the program, you can undo (Ctrl Z) or redo (Ctrl Y) each stage to see what it does.

Stage one

The first commented section is giving a brief explaination of the script-fu, along with the GNU General Public License.

Stage two

Define the script-fu, in this case contrast-lite and any paramaters added (img, drw etc.)

Stage three

The actual script (actions from 1 to 8), including, in this case, an undo start and end for each action. Normally this would be done once at the start and end of the script.

Stage four

The script-fu registration section allows you to add location, description and copyright info. In this example it also has info needed for the Blur Radius and Opacity slider settings.


; contrast-lite.scm version 2.6v3
; 01 December 2008
; A Script-Fu script to correct the exposure of dark areas without overexposing bright areas
; Modified to replace deprecated procedures, to work with GIMP 2.6

; 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.

; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


; define script-fu function and parameters
	(define (script-fu-contrast-lite img drw gbr msk)

; 1. copy image
	(gimp-image-undo-group-start img)
	(let* ((contrast (car (gimp-layer-copy drw 1))))
	(gimp-image-undo-group-end img)

; 2. add copied image as new layer
	(gimp-image-undo-group-start img)
	(gimp-image-add-layer img contrast -1)
	(gimp-image-undo-group-end img)

; 3. desaturate new layer
	(gimp-image-undo-group-start img)
	(gimp-desaturate contrast)
	(gimp-image-undo-group-end img)

; 4. invert new layer
	(gimp-image-undo-group-start img)
	(gimp-invert contrast)
	(gimp-image-undo-group-end img)

; 5. perform gaussian-blur on new layer
	(gimp-image-undo-group-start img)
	(plug-in-gauss-iir 1 img contrast gbr 1 1)
	(gimp-image-undo-group-end img)

; 6. set opacity on new layer
	(gimp-image-undo-group-start img)
	(gimp-layer-set-opacity contrast msk)
	(gimp-image-undo-group-end img)

; 7. set mode to overlay on new layer
	(gimp-image-undo-group-start img)
	(gimp-layer-set-mode contrast OVERLAY-MODE)
	(gimp-image-undo-group-end img)

; 8. set layer name to contrast
	(gimp-image-undo-group-start img)
	(gimp-drawable-set-name contrast "contrast")
	(gimp-image-undo-group-end img)

;this is the closing bracket for the let* variable at 1.
)

; flush all changes to user interface
	(gimp-displays-flush)

;this is the closing bracket for the script-fu
)

;this is where the script-fu registration information goes
(script-fu-register "script-fu-contrast-lite"
		_"<Image>/Script-Fu/Underwater Photos/_Contrast Lite"
		"Create a contrast layer"
		"www.tankedup-imaging.com"
		"Tanked Up Underwater Imaging"
		"01 December 2008"
		""
		SF-IMAGE "Image" 0
		SF-DRAWABLE "Drawable" 0
		SF-ADJUSTMENT _"Blur Radius" '(20 1 200 1 10 0 0)
		SF-ADJUSTMENT "Opacity" '(80 0 100 1 10 0 0)
)

Script-Fu downloads

Correcting lighting imbalance and dark shadows

Contrast Mask | Method 1

This script-fu will add a contrast mask to your image along with hue and saturation layers from your original, this should correct the exposure of dark areas without overexposing bright areas.

When you run this script-fu it will come up with an option box for blur radius and opacity. The default blur radius is set to 20px, as a ball park figure set the blur radius to 1% of the average picture size. A blur radius calculator can be found on the contrast mask tutorial page.

The opacity default is 80%, this can be changed after the script-fu has run if necessary.

The full tutorial can be found at Contrast Mask tutorial.

Restoring reds back into blue/green underwater images

All these script-fu's will enhance the red that is lost on underwater photographs taken without a flash.

The opacity default on all is 50%, this can be changed after the script-fu has run. Increasing the percentage of opacity will increase the red enhancement.

Red Enhance | Method 1

This script-fu is based on the mandrake method for Photoshop. The one difference is setting the mode of the luminosity layer to value.

The full tutorial can be found at Red Enhance tutorial 1.

Red Enhance | Method 2

This script-fu is a GIMP version of the mandrake method for Photoshop. The main difference with this method is that the grey layer has a mode setting of colour and the screen layer isn't then merged to another copy of the original.

The full tutorial can be found at Red Enhance tutorial 2.

Resizing and sharpening images

A modified 25% scaling and unsharp mask script-fu for the gallery images on the site. All our images are high resolution and this reduces it by 50%, performs an unsharp mask , reduces to gallery size (524x393) and unsharp masks again.

The full tutorial can be found at Unsharp Mask tutorial.

GNU General Public License

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.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Download GIMP Graphics by GIMP