; Black&white scripts ; Version 0.1 ; ; Copyright (c) 2004, Vincent Richard ; vincent@vincent-richard.net ; ; 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. ;=================== ; Toned black&white ;=================== (script-fu-register "script-fu-bw-toned-bw" "/Script-Fu/Black&White/Toned Black&White" "Add an overall color (toning) to a black&white image" "Vincent Richard" "Copyright (c) Vincent Richard, 2004" "October 2004" "RGB*, GRAY*" SF-IMAGE "Image" 0 SF-DRAWABLE "Layer" 0 SF-COLOR "Color for dark areas" '(110 81 38) SF-COLOR "Color for light areas" '(128 130 179) ; '(122 123 141) ) (define (script-fu-bw-toned-bw image origLayer darkColor lightColor) (gimp-image-undo-group-start image) (gimp-selection-none image) ; Flatten the image (gimp-image-flatten image) ; Get active layer (unique layer of the image) (set! layer (car (gimp-image-get-active-layer image))) ; Convert to RGB (if (< 0 (car (gimp-image-base-type image))) (gimp-image-convert-rgb image)) ; Get image size (set! width (car (gimp-image-width image))) (set! height (car (gimp-image-height image))) ; Dark tone (set! darkLayer (car (gimp-layer-new image width height 1 "DarkTone" 100.0 13))) ; 1 = GIMP_RGBA_IMAGE, 13 = GIMP_COLOR_MODE (gimp-image-add-layer image darkLayer -1) (gimp-palette-set-foreground darkColor) (gimp-edit-fill darkLayer 0) ; 0 = GIMP_FOREGROUND_FILL (set! darkMask (car (gimp-layer-create-mask darkLayer 0))) ; 0 = GIMP_ADD_WHITE_MASK (gimp-layer-add-mask darkLayer darkMask) (gimp-edit-copy layer) (gimp-floating-sel-anchor (car (gimp-edit-paste darkMask 0))) (gimp-invert darkMask) (gimp-selection-none image) ; Light tone (set! lightLayer (car (gimp-layer-new image width height 1 "LightTone" 100.0 13))) ; 1 = GIMP_RGBA_IMAGE, 13 = GIMP_COLOR_MODE (gimp-image-add-layer image lightLayer -1) (gimp-palette-set-foreground lightColor) (gimp-edit-fill lightLayer 0) ; 0 = GIMP_FOREGROUND_FILL (set! lightMask (car (gimp-layer-create-mask lightLayer 0))) ; 0 = GIMP_ADD_WHITE_MASK (gimp-layer-add-mask lightLayer lightMask) (gimp-edit-copy layer) (gimp-floating-sel-anchor (car (gimp-edit-paste lightMask 0))) (gimp-selection-none image) ; Final adjustment (gimp-layer-set-opacity darkLayer 70) (gimp-layer-set-opacity lightLayer 80) ; Flush the display (gimp-image-undo-group-end image) (gimp-displays-flush) ) ;====================== ; Filtered black&white ;====================== (script-fu-register "script-fu-bw-filter-bw" "/Script-Fu/Black&White/Filtered Black&White" "Simulate color filter on black&white films" "Vincent Richard" "Copyright (c) Vincent Richard, 2004" "October 2004" "RGB*, GRAY*" SF-IMAGE "Image" 0 SF-DRAWABLE "Layer" 0 SF-OPTION "Filter Color" '("Yellow" "Orange" "Green") ) (define (script-fu-bw-filter-bw image layer filterColor) (gimp-image-undo-group-start image) (gimp-selection-none image) ; Apply color filter (if (= filterColor 0) ; Yellow: 60/28/15 (plug-in-colors-channel-mixer 1 image layer TRUE 0.60 0.28 0.15 0.60 0.28 0.15 0.60 0.28 0.15)) (if (= filterColor 1) ; Orange: 78/22/0 (plug-in-colors-channel-mixer 1 image layer TRUE 0.78 0.22 0.0 0.78 0.22 0.0 0.78 0.22 0.0)) (if (= filterColor 2) ; Green: 10/70/20 (plug-in-colors-channel-mixer 1 image layer TRUE 0.10 0.70 0.20 0.10 0.70 0.20 0.10 0.70 0.20)) ; Flush the display (gimp-image-undo-group-end image) (gimp-displays-flush) )