/
The_bigger_hammer_0.scm
235 lines (219 loc) · 6.61 KB
/
The_bigger_hammer_0.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
(script-fu-register
"bigger-hammer" ;func name
"The bigger hammer" ;menu label
"Implements Dan Margulis concept, The Bigger Hammer, from Modern Photoshop Color Workflow" ;description
"Stig Junge" ;author
"copyright 2014, Stig Junge" ;copyright notice
"February 16, 2014" ;date created
"" ;image type that the script works on
SF-IMAGE "Input Image" 0
SF-OPTION "Channel to use" '("Red channel" "Green channel" "Blue channel" "RGB")
SF-OPTION "Mode" '("Overlay" "Soft light")
SF-OPTION "Protection" '("Dark areas" "Light areas")
SF-ADJUSTMENT "Radius" '(25 0 300 0 0 0 0)
)
(script-fu-menu-register "bigger-hammer" "<Image>/Filters/Enhance")
(define (bigger-hammer inImage overlay mode protection radius)
;get specific layer in image
(define (get-specified-layer theImage theLayerNumber)
(let*
(
(theRequestedLayer 0)
)
(set! theRequestedLayer
(vector-ref
(cadr
(gimp-image-get-layers theImage)
)
theLayerNumber
)
)
(list theRequestedLayer)
)
)
;make a copy of layer number X and get the reference
(define (copy-specified-layer theImage theLayerNumber)
(let*
(
(theRequestedLayer 0)
)
(set! theRequestedLayer
(car
( gimp-layer-copy
(car (get-specified-layer theImage theLayerNumber))
FALSE
)
)
)
(list theRequestedLayer)
)
)
(let*
(
(theImage inImage) ;The input image
(theLayer 0) ;
(RGB_Image 0)
(theCurrentLayer 0) ;The layer currently in question
(theOriginalLayer 0) ;The original layer to copy from
(theCopy 0)
(theFloat 0) ;Floating selection after copy-paste
)
(gimp-context-push)
(gimp-image-undo-group-start theImage)
;Insert a greyscale copy of the red, green or blue channel - or the RGB-composite
(if (= overlay 3)
;Insert the RGB-composite as a new layer
(begin
;Get af copy of the original layer
(set! theOriginalLayer (car (get-specified-layer theImage 0)))
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(gimp-edit-copy theOriginalLayer)
(define theFloat
(car
(gimp-edit-paste theCurrentLayer 1)
)
)
(gimp-floating-sel-to-layer theFloat)
;Insert as a new layer
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(gimp-desaturate-full theCurrentLayer DESATURATE-LUMINOSITY)
)
;ELSE
(begin
;Get the original layer
(set! theLayer (car (get-specified-layer theImage 0)))
;Decompose to RGB
(define RGB_Image
(car
(plug-in-decompose RUN-NONINTERACTIVE theImage theLayer "RGB" TRUE)
)
)
;Copy red channel from RGB-image
(if (= overlay 0)
(begin
(set! theCopy
(car
(gimp-edit-copy
(car
(gimp-image-get-layer-by-name RGB_Image "red")
)
)
)
)
)
()
)
;Copy green channel from RGB-image
(if (= overlay 1)
(begin
(set! theCopy
(car
(gimp-edit-copy
(car
(gimp-image-get-layer-by-name RGB_Image "green")
)
)
)
)
)
()
)
;Copy blue channel from RGB-image
(if (= overlay 2)
(begin
(set! theCopy
(car
(gimp-edit-copy
(car
(gimp-image-get-layer-by-name RGB_Image "blue")
)
)
)
)
)
()
)
;Insert the copy
(set! theFloat
(car
(gimp-edit-paste theLayer 1)
)
)
;Convert floating layer to layer
(gimp-floating-sel-to-layer theFloat)
)
)
;Invert and blur the inserted layer
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(gimp-invert theCurrentLayer)
(plug-in-gauss 1 theImage theCurrentLayer radius radius 1)
(gimp-layer-set-opacity theCurrentLayer 50)
(if (= mode 0)
(begin
;Copy the original to a new layer...
;Get reference to original layer
(set! theOriginalLayer (car (get-specified-layer theImage 1)))
;Make a copy of the original layer
(gimp-edit-copy theOriginalLayer)
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
;Insert the copy
(set! theFloat
(car
(gimp-edit-paste theCurrentLayer 1)
)
)
;Convert floating layer to layer (hardlight mode layer for merge down with grayscale layer)
(gimp-floating-sel-to-layer theFloat)
;Get reference to topmost layer
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
;Set layer mode to hard light
(gimp-layer-set-mode theCurrentLayer HARDLIGHT-MODE)
;Merge down
(gimp-image-merge-down inImage theCurrentLayer 0)
)
(gimp-layer-set-mode theCurrentLayer SOFTLIGHT-MODE)
)
;Rename the topmost layer
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(gimp-item-set-name theCurrentLayer "Overlay")
;Copy the original to a new layer (darken-only layer)
(set! theLayer (car (get-specified-layer theImage 0)))
(set! theCurrentLayer (car (get-specified-layer theImage 1)))
(gimp-edit-copy theCurrentLayer)
(define theFloat
(car
(gimp-edit-paste theLayer 1)
)
)
(gimp-floating-sel-to-layer theFloat)
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(if (= protection 0)
(begin
(gimp-layer-set-mode theCurrentLayer DARKEN-ONLY-MODE)
(gimp-item-set-name theCurrentLayer "Darken only")
)
(begin
(gimp-layer-set-mode theCurrentLayer LIGHTEN-ONLY-MODE)
(gimp-item-set-name theCurrentLayer "Lighten only")
)
)
;Set opacity to 50%
(gimp-layer-set-opacity theCurrentLayer 50)
;Copy the original layer to the "Unblurred" layer...
(set! theLayer (car (get-specified-layer theImage 0)))
(set! theCurrentLayer (car (get-specified-layer theImage 2)))
(gimp-edit-copy theCurrentLayer)
(define theFloat
(car
(gimp-edit-paste theLayer 1)
)
)
(gimp-floating-sel-to-layer theFloat)
(set! theCurrentLayer (car (get-specified-layer theImage 0)))
(gimp-item-set-name theCurrentLayer "Unblurred")
(gimp-item-set-visible theCurrentLayer 0)
(gimp-image-undo-group-end theImage)
(gimp-context-pop)
(gimp-displays-flush)
)
)