;; -*-scheme-*- ;; Copyright, Alan Horkan 2004. (define (script-fu-invert-colours image drawable) (gimp-image-undo-group-start image) ;; what you see is not always what you get ;; if the canvas has been resized the drawable can be offscreen ;; making selection gets only onscreen parts of the drawable (if (= (car (gimp-selection-is-empty image)) TRUE) (gimp-selection-all image) ) ;; it is easier to copy, paste and promote than to create a new layer ;; and need to mess about trying to position it. ;; copy the original layer or selection (gimp-edit-copy drawable) ;; set this as layer one, even if it is not a proper layer yet ... (set! layer-1 (car (gimp-edit-paste drawable FALSE))) (gimp-floating-sel-to-layer layer-1) ;; ... but it is now ;; dont want a layer called "Pasted Layer", so change it ;(gimp-drawable-set-name layer-1 _"Greyscale Inverse") ;; copy layer (set! layer-2 (car (gimp-layer-copy layer-1 TRUE))) (gimp-image-add-layer image layer-2 -1) ;; good to have layer names, but unnecessary for the final result ;(gimp-drawable-set-name layer-2 _"Colour Mode") ;; convert to grayscale/black and white/desaturate ; (gimp-desaturate layer-1) ;; turns out this isn't even necessary, the invert is what is important ;; invert the colours (gimp-invert layer-2) ;; add the colours back, colour mode (13) (gimp-layer-set-mode layer-2 13) ;; merge the layers temporary layers together into the final layer (set! layer-3 (car (gimp-image-merge-down image layer-2 0))) ;; give the resulting layer a name (gimp-drawable-set-name layer-3 _"Inverted Colours Effect") ;; one could merge again and be left with just the one layer but ;; better to keep the layer for future modifications and adjustment (gimp-image-undo-group-end image) (gimp-displays-flush) ) ;; alternative location. put in same place as the other invert ;(set! menu-path _"/Layer/Colors/") ;(set! menu-path _"/Filters/") ;; incomplete localisation forces me to use American English. ;(set! menu-path _"/Filters/Colours/Invert Colours") ; en-US, American English. (set! menu-path _"/Filters/Colors/Invert Colors") ; en, English. (set! authors "Alan Horkan. ") (set! rights "Alan Horkan, 2004. ") (set! date "2004 04 02 UTC") (script-fu-register "script-fu-invert-colours" ;; (string-append menu-path) _"/Filters/Colors/Invert Colors") ;; help description "Invert Colours but leave the light and dark alone. " "Alan Horkan" rights date "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 ) ;; see also Tachyon/Invert Light, on which this script was based