-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFU_color_bw-from-graphic.scm
217 lines (202 loc) · 7.97 KB
/
FU_color_bw-from-graphic.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
; FU_color_bw-from-graphic.scm
; version 2.9 [gimphelp.org]
; last modified/tested by Paul Sherman
; 02/15/2014 on GIMP-2.8.10
; 04/26/2020 on GIMP-2.10.18
; edited by Paul Sherman
; and then by karlhof26
;
; A derivative of BW Film Simulation,
; made for use specifically for rendering clip art
; in greyscale. High-Contrast setting will yield a
; "sketchy" look instead of the usual "blockinesss"
; usually rendered from graphics when converting to grey.
;
;==============================================================
;
; Installation:
; This script should be placed in the user or system-wide script folder.
;
; Windows Vista/7/8)
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Users\YOUR-NAME\.gimp-2.8\scripts
;
; Windows XP
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Documents and Settings\yourname\.gimp-2.8\scripts
;
; Linux
; /home/yourname/.gimp-2.8/scripts
; or
; Linux system-wide
; /usr/share/gimp/2.0/scripts
;
;==============================================================
;
; 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 3 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, see <http://www.gnu.org/licenses/>.
;
;==============================================================
; Original information
; Serge Mankovski B/W Film Simulation
;
; Modified by Paul Sherman 12/30/2007
; made to work with GIMP-2.4+
; simplified film type menu
; modified (xtra steps) in High-Contrast for use with graphics
; (to compensate for the "blockiness" when rendering clip art,
; yielding a lighter "sketched" look.)
;
; Copyright Serge Mankovski (sevato@mankovski.com)
; Toronto, Ontario, 2007
;
; Version 1.1 March 30, 2007
; Converts selected layer into Black and White using channel mixer
; Uses channel presets found on Internet. I am not sure about the origin of these
; settings and I do not know if they really produce result resembling tonal qualities of
; the film, but it produces nice looking B/W and it is a useful way to convert to black and white
;
; Change Log:
; Version 1.1
; - added IR film simulation
; - added color filters applied before b/w conversion
; - added saturation option
; - Gimp 2.3.15+ support
; Version 1.2
; Support for Gimp.10.32 - Updated by karlhof26
;==============================================================
(define (create-new-layer img drawable)
(define layer (car (gimp-layer-copy drawable TRUE)))
(gimp-image-insert-layer img layer 0 -1)
layer
)
(define (FU-bw-from-graphic
img
drawable
film
filter
rename
new-layer
increase-local-contrast
auto-levels
drop-gamma
saturate
)
(gimp-image-undo-group-start img)
(if (not (= RGB (car (gimp-image-base-type img))))
(gimp-image-convert-rgb img)
)
(let*
(
(bw-layer img)
(chan-name "")
)
(if (equal? new-layer TRUE)
(set! bw-layer (create-new-layer img drawable))
(set! bw-layer drawable)
)
(if (equal? saturate TRUE)
(plug-in-colors-channel-mixer 1 img bw-layer FALSE 1.3 -0.15 -0.15 -0.15 1.3 -0.15 -0.15 -0.15 1.3)
()
)
(if (equal? drop-gamma TRUE)
(begin
;(gimp-levels bw-layer 0 0 255 0.9 0 255)
(gimp-drawable-levels bw-layer HISTOGRAM-VALUE 0.0 1.0 TRUE 0.9 0.0 1.0 TRUE)
)
()
)
(cond
; Yellow Filter
((= filter 1)
;(gimp-hue-saturation bw-layer 0 -5 0 33)
(gimp-drawable-hue-saturation bw-layer HUE-RANGE-ALL -5 0 33 0)
(set! chan-name (string-append chan-name " Yellow Filter")))
; Orange Filter
((= filter 2)
;(gimp-hue-saturation bw-layer 0 -20 0 25)
(gimp-drawable-hue-saturation bw-layer HUE-RANGE-ALL -20 0 25 0)
(set! chan-name (string-append chan-name " Orange Filter")))
; Red Filter
((= filter 3)
;(gimp-hue-saturation bw-layer 0 -41 0 25)
(gimp-drawable-hue-saturation bw-layer HUE-RANGE-ALL -41 0 25 0)
(set! chan-name (string-append chan-name " Red Filter")))
; Green Filter
((= filter 4)
;(gimp-hue-saturation bw-layer 0 90 0 33)
(gimp-drawable-hue-saturation bw-layer HUE-RANGE-ALL 90 0 33 0)
(set! chan-name (string-append chan-name " Green Filter")))
; Blue Filter
((= filter 5)
;(gimp-hue-saturation bw-layer 0 -145 0 25)
(gimp-drawable-hue-saturation bw-layer HUE-RANGE-ALL -145 0 25 0)
(set! chan-name (string-append chan-name " Blue Filter")))
)
(cond
; High Contrast
((= film 0)
(set! chan-name (string-append chan-name " High Contrast"))
(plug-in-colors-channel-mixer 1 img bw-layer TRUE 0.40 0.34 0.60 0.40 0.34 0.60 0.40 0.34 0.60 )
;(gimp-levels bw-layer HISTOGRAM-VALUE 0 255 1.4 1 255)
(gimp-drawable-levels bw-layer HISTOGRAM-VALUE 0.0 1.0 TRUE 1.4 0.05 1.0 TRUE)
(gimp-drawable-brightness-contrast bw-layer 0.0 0.3)
)
(plug-in-unsharp-mask 1 img bw-layer 5.0 0.30 10)
; Normal Contrast
((= film 1)
(set! chan-name (string-append chan-name " Normal Contrast"))
(plug-in-colors-channel-mixer 1 img bw-layer TRUE 0.43 0.33 0.30 0.43 0.33 0.30 0.43 0.33 0.30 )
)
)
(if (equal? rename TRUE) (gimp-item-set-name bw-layer chan-name) () )
(if (equal? increase-local-contrast TRUE) (plug-in-unsharp-mask 1 img bw-layer 30.0 0.25 9) ())
(if (= auto-levels TRUE) (gimp-drawable-levels-stretch bw-layer) ())
(gimp-image-convert-grayscale img)
(gimp-image-undo-group-end img)
(gimp-displays-flush)
)
)
(script-fu-register "FU-bw-from-graphic"
"<Toolbox>/Script-Fu/Colors/BW from Graphic"
"Black and White From a Color Graphic. Made for use specifically for rendering clip art in greyscale. High-Contrast setting will yield a sketchy look instead of the blockinesss usually rendered from graphics when converting to grey.\n\nby Paul Sherman\ngimphelp.org \n file:FU_color_bw-from-graphic.scm"
"Modified version by Paul Sherman <psherman201@gmail.com>
Original by Serge Mankovski (sevato@mankvoski.com)
Original copyright info below:"
"2007, Serge Mankovski, Toronto, ON, Canada"
"05.01.2007"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Current Layer" 0
SF-OPTION "Film" '("High Contrast" "Normal Contrast")
SF-OPTION "Filter"
'(
"Select"
"Yellow"
"Orange"
"Red"
"Green"
"Blue"
)
SF-TOGGLE "Rename Layer?" TRUE
SF-TOGGLE "New Layer?" FALSE
SF-TOGGLE "Increase Local Contrast" FALSE
SF-TOGGLE "Auto Levels" FALSE
SF-TOGGLE "Drop Gamma 10%" FALSE
SF-TOGGLE "Saturate" FALSE
)
; end of script