; GIMP Script-Fu ; Anaglypher -- make anaglyphic 3D picture from a left and right image ; Author: Christian Steinruecken (define (anaglyph-tf img layL layR color-L color-R) (gimp-undo-push-group-start img) ; name the left-eye channel (gimp-drawable-set-name layL "LEFT") ; name the right-eye layer (gimp-drawable-set-name layR "RIGHT") ; select everything (gimp-selection-all img) ; desaturate and colourise right layer (gimp-desaturate-full layR DESATURATE-LUMINOSITY) (gimp-context-set-foreground color-R) (gimp-edit-bucket-fill layR FG-BUCKET-FILL MULTIPLY-MODE 100 0 FALSE 1 1) ; desaturate and colourise left layer (gimp-desaturate-full layL DESATURATE-LUMINOSITY) (gimp-context-set-foreground color-L) (gimp-edit-bucket-fill layL FG-BUCKET-FILL MULTIPLY-MODE 100 0 FALSE 1 1) ; de-select (gimp-selection-none img) ; combine the two layers (gimp-layer-set-mode layR SCREEN-MODE) (let* ( (layCMB (car (gimp-image-merge-down img layR EXPAND-AS-NECESSARY))) ) (gimp-drawable-set-name layCMB "COMBINED") (gimp-undo-push-group-end img) ; return identity of combined layer (list layCMB) ) ) (define (anaglyph-conv fnm-L fnm-R fnm-DEST color-L color-R) (let* ((img (car (gimp-file-load RUN-NONINTERACTIVE fnm-L fnm-L))) (layL (car (gimp-image-get-active-layer img))) (layR (car (gimp-file-load-layer RUN-NONINTERACTIVE img fnm-R)))) ; insert the right-eye layer (gimp-image-add-layer img layR 0) ; do anaglyphic transform (let* ( (layFINAL (car (anaglyph-tf img layL layR color-L color-R))) ) ; save it (gimp-file-save RUN-NONINTERACTIVE img layFINAL fnm-DEST fnm-DEST) ) ; the end (gimp-displays-flush) ) ) (define (anaglypher fnm-L fnm-R color-L color-R) (let* ( (img (car (gimp-file-load RUN-NONINTERACTIVE fnm-L fnm-L))) (layL (car (gimp-image-get-active-layer img))) (layR (car (gimp-file-load-layer RUN-NONINTERACTIVE img fnm-R))) ) ; insert the right-eye layer (gimp-image-add-layer img layR 0) ; do anaglyphic transform (let* ( (layFINAL (car (anaglyph-tf img layL layR color-L color-R))) ) (gimp-display-new img) ) ; the end (gimp-displays-flush) ) ) ; register the script? (script-fu-register "anaglypher" "Anaglypher" "Creates an anaglyphic stereo image from two input images" "Christian Steinruecken " "Christian Steinruecken" "2010-04-20" "" SF-FILENAME "fnm-L" "" SF-FILENAME "fnm-R" "" SF-COLOR "color-L" '(255 0 0) SF-COLOR "color-R" '(0 255 255) ;SF-FILENAME "Output" "output.rcs.png" ) (script-fu-menu-register "anaglypher" "/Filters") ; register the automated function, too (script-fu-register "anaglyph-conv" "Automated Anaglyph Converter" "Creates an anaglyphic stereo image from two input images" "Christian Steinruecken " "Christian Steinruecken" "2010-04-21" "" SF-FILENAME "fnm-L" "" SF-FILENAME "fnm-R" "" SF-FILENAME "Output" "" SF-COLOR "color-L" '(255 0 0) SF-COLOR "color-R" '(0 255 255) ) (script-fu-menu-register "anaglyph-conv" "/Filters")