Skip to content

Commit 83000c5

Browse files
authored
Uploaded script. Deep color effect.
1 parent 9d0b0a5 commit 83000c5

File tree

1 file changed

+234
-0
lines changed

1 file changed

+234
-0
lines changed

elsamuko-deep-color.scm

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
; The GIMP -- an image manipulation program
2+
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
3+
;
4+
; This program is free software; you can redistribute it and/or modify
5+
; it under the terms of the GNU General Public License as published by
6+
; the Free Software Foundation; either version 3 of the License, or
7+
; (at your option) any later version.
8+
;
9+
; This program is distributed in the hope that it will be useful,
10+
; but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
; GNU General Public License for more details.
13+
;
14+
; You should have received a copy of the GNU General Public License
15+
; along with this program; if not, write to the Free Software
16+
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17+
; http://www.gnu.org/licenses/gpl-3.0.html
18+
;
19+
; Copyright (C) 2010 elsamuko <[email protected]>
20+
;
21+
22+
(define (elsamuko-deep-color aimg adraw
23+
color1 color2
24+
desaturation overlay
25+
gamma multiply
26+
redtint grain
27+
edge extra-dark)
28+
(let* (
29+
(img (car (gimp-item-get-image adraw)))
30+
(owidth (car (gimp-image-width img)))
31+
(oheight (car (gimp-image-height img)))
32+
(desat-layer (car (gimp-layer-copy adraw FALSE)))
33+
(multiply-layer (car (gimp-layer-copy adraw FALSE)))
34+
(multiply-layer2 (car (gimp-layer-copy adraw FALSE)))
35+
(multiply-layer2-mask (car (gimp-layer-create-mask multiply-layer2 ADD-MASK-WHITE)))
36+
(edge-layer (car (gimp-layer-copy adraw FALSE)))
37+
(red-layer 0)
38+
(overlay-layer1 (car (gimp-layer-copy adraw FALSE)))
39+
(overlay-layer2 (car (gimp-layer-copy adraw FALSE)))
40+
(yellow-layer (car (gimp-layer-new img
41+
owidth
42+
oheight
43+
RGBA-IMAGE
44+
"Yellow Multiply"
45+
10
46+
LAYER-MODE-MULTIPLY-LEGACY)))
47+
(sepia-layer (car (gimp-layer-new img
48+
owidth
49+
oheight
50+
RGBA-IMAGE
51+
"Sepia"
52+
50
53+
LAYER-MODE-GRAIN-MERGE)))
54+
(grain-layer (car (gimp-layer-new img
55+
owidth
56+
oheight
57+
1
58+
"Grain"
59+
100
60+
LAYER-MODE-OVERLAY-LEGACY)))
61+
(grain-layer-mask (car (gimp-layer-create-mask grain-layer ADD-MASK-WHITE)))
62+
)
63+
64+
; init
65+
(define (set-pt a index x y)
66+
(begin
67+
(aset a (* index 2) x)
68+
(aset a (+ (* index 2) 1) y)
69+
)
70+
)
71+
(define (splineValue)
72+
(let* (
73+
(a (cons-array 6 'double))
74+
)
75+
(set-pt a 0 0.0 0.0)
76+
(set-pt a 1 0.502 (/ grain 255))
77+
(set-pt a 2 1.0 0.0)
78+
a
79+
)
80+
)
81+
82+
(gimp-context-push)
83+
(gimp-image-undo-group-start img)
84+
(if (= (car (gimp-drawable-is-gray adraw )) TRUE)
85+
(gimp-image-convert-rgb img)
86+
)
87+
88+
;some more red
89+
(gimp-image-insert-layer img edge-layer 0 0)
90+
(gimp-item-set-name edge-layer "Edge Amp")
91+
(gimp-color-balance edge-layer TRANSFER-MIDTONES TRUE 20 0 0)
92+
(gimp-color-balance edge-layer TRANSFER-HIGHLIGHTS TRUE 20 0 0)
93+
94+
(gimp-layer-set-mode edge-layer LAYER-MODE-GRAIN-EXTRACT)
95+
(gimp-edit-copy-visible img)
96+
(set! red-layer (car (gimp-layer-new-from-visible img img "Red")))
97+
(gimp-image-insert-layer img red-layer 0 0)
98+
(gimp-layer-set-mode red-layer LAYER-MODE-GRAIN-MERGE)
99+
(gimp-layer-set-opacity red-layer redtint)
100+
(gimp-drawable-invert red-layer FALSE)
101+
(gimp-item-set-visible edge-layer FALSE)
102+
103+
;set desaturated and multiply layer
104+
(gimp-image-insert-layer img desat-layer 0 -1)
105+
(gimp-item-set-name desat-layer "Desaturated")
106+
(gimp-layer-set-mode desat-layer LAYER-MODE-NORMAL-LEGACY)
107+
(gimp-layer-set-opacity desat-layer 100)
108+
(gimp-drawable-hue-saturation desat-layer HUE-RANGE-ALL 0 0 desaturation 2) ; overlap was 0
109+
110+
(gimp-image-insert-layer img multiply-layer 0 -1)
111+
(gimp-item-set-name multiply-layer "Multiply 1")
112+
(gimp-layer-set-mode multiply-layer LAYER-MODE-MULTIPLY)
113+
(gimp-layer-set-opacity multiply-layer multiply)
114+
(gimp-drawable-hue-saturation multiply-layer HUE-RANGE-ALL 0 0 desaturation 5) ; overlap was 0
115+
116+
(if(= extra-dark TRUE)
117+
(begin
118+
(gimp-image-insert-layer img multiply-layer2 0 -1)
119+
(gimp-item-set-name multiply-layer2 "Multiply 2")
120+
(gimp-layer-set-mode multiply-layer2 LAYER-MODE-MULTIPLY)
121+
(gimp-layer-set-opacity multiply-layer2 100)
122+
(gimp-drawable-desaturate multiply-layer2 DESATURATE-LUMINANCE)
123+
(gimp-layer-add-mask multiply-layer2 multiply-layer2-mask)
124+
125+
(gimp-selection-all img)
126+
(gimp-edit-copy multiply-layer2)
127+
(gimp-floating-sel-anchor (car (gimp-edit-paste multiply-layer2-mask TRUE)))
128+
)
129+
)
130+
131+
;set overlay layers
132+
(gimp-image-insert-layer img overlay-layer1 0 -1)
133+
(gimp-item-set-name overlay-layer1 "Overlay 1")
134+
(gimp-layer-set-mode overlay-layer1 LAYER-MODE-OVERLAY)
135+
(gimp-layer-set-opacity overlay-layer1 overlay)
136+
(gimp-drawable-desaturate overlay-layer1 DESATURATE-LUMINANCE)
137+
(gimp-drawable-levels overlay-layer1 HISTOGRAM-VALUE 0.25 0.6 TRUE gamma 0.0 1.0 TRUE) ; was 70 150 gamma
138+
139+
(gimp-image-insert-layer img overlay-layer2 0 -1)
140+
(gimp-item-set-name overlay-layer2 "Overlay 2")
141+
(gimp-layer-set-mode overlay-layer2 LAYER-MODE-OVERLAY)
142+
(gimp-layer-set-opacity overlay-layer2 overlay)
143+
(gimp-drawable-desaturate overlay-layer2 DESATURATE-LUMINANCE)
144+
(gimp-drawable-levels overlay-layer2 HISTOGRAM-VALUE 0.25 0.61 TRUE gamma 0.0 1.0 TRUE)
145+
146+
;set yellow multiply layer
147+
(gimp-image-insert-layer img yellow-layer 0 -1)
148+
(gimp-selection-all img)
149+
(gimp-context-set-foreground color2)
150+
(gimp-edit-bucket-fill yellow-layer BUCKET-FILL-FG LAYER-MODE-NORMAL 100 0 FALSE 0 0)
151+
152+
;set sepia grain merge layer
153+
(gimp-image-insert-layer img sepia-layer 0 -1)
154+
(gimp-selection-all img)
155+
(gimp-context-set-foreground color1)
156+
(gimp-edit-bucket-fill sepia-layer BUCKET-FILL-FG LAYER-MODE-NORMAL 100 0 FALSE 0 0)
157+
158+
;move red tint layer to top
159+
(gimp-image-raise-item-to-top img red-layer)
160+
161+
;add grain
162+
(if (> grain 0)
163+
(begin
164+
;fill new layer with neutral gray
165+
(gimp-image-insert-layer img grain-layer 0 -1)
166+
(gimp-drawable-fill grain-layer FILL-TRANSPARENT)
167+
(gimp-context-set-foreground '(128 128 128))
168+
(gimp-selection-all img)
169+
(gimp-edit-bucket-fill grain-layer BUCKET-FILL-FG LAYER-MODE-NORMAL 100 0 FALSE 0 0)
170+
(gimp-selection-none img)
171+
172+
;add grain and blur it
173+
(plug-in-hsv-noise 1 img grain-layer 2 0 1 100) ; was 2 0 0 100
174+
(plug-in-gauss 1 img grain-layer 0.5 0.5 1)
175+
(gimp-layer-add-mask grain-layer grain-layer-mask)
176+
177+
;select the original image, copy and paste it as a layer mask into the grain layer
178+
(gimp-selection-all img)
179+
(gimp-edit-copy adraw)
180+
(gimp-floating-sel-anchor (car (gimp-edit-paste grain-layer-mask TRUE)))
181+
182+
;set color curves of layer mask, so that only gray areas become grainy
183+
(gimp-drawable-curves-spline grain-layer-mask HISTOGRAM-VALUE 6 (splineValue))
184+
)
185+
)
186+
187+
188+
;edge detection
189+
(if (= edge TRUE)
190+
(begin
191+
(gimp-image-raise-item-to-top img edge-layer)
192+
(gimp-item-set-visible edge-layer TRUE)
193+
(plug-in-sobel TRUE img edge-layer TRUE TRUE TRUE)
194+
(gimp-drawable-levels-stretch edge-layer)
195+
(gimp-drawable-desaturate edge-layer DESATURATE-LUMINANCE)
196+
(gimp-drawable-invert edge-layer FALSE)
197+
(gimp-layer-set-mode edge-layer LAYER-MODE-MULTIPLY)
198+
(gimp-layer-set-opacity edge-layer 50)
199+
)
200+
)
201+
202+
; tidy up
203+
(gimp-image-undo-group-end img)
204+
(gimp-displays-flush)
205+
(gimp-context-pop)
206+
; we used an array so do a garbage collection
207+
(gc)
208+
)
209+
)
210+
211+
(script-fu-register "elsamuko-deep-color"
212+
"Deep color"
213+
"Cinematic Deep Color effect. \nfile: elsamuko-deep-color.scm"
214+
"elsamuko <[email protected]>"
215+
"elsamuko"
216+
"04/03/10"
217+
"RGB*"
218+
SF-IMAGE "Input image" 0
219+
SF-DRAWABLE "Input drawable" 0
220+
SF-COLOR "Grain Merge" '(160 141 105)
221+
SF-COLOR "Multiply" '(241 229 31)
222+
SF-ADJUSTMENT "Desaturation" '(-60 -100 0 1 10 0 0)
223+
SF-ADJUSTMENT "Overlay Opacity" '( 60 0 100 1 10 0 0)
224+
SF-ADJUSTMENT "Overlay Gamma" '( 2 1 3 0.1 0.2 1 0)
225+
SF-ADJUSTMENT "Multiply Opacity" '( 50 0 100 1 10 0 0)
226+
SF-ADJUSTMENT "Red Tint Opacity" '( 80 0 100 1 10 0 0)
227+
SF-ADJUSTMENT "Grain Strength" '(128 0 255 1 10 0 0)
228+
SF-TOGGLE "Edge Amplification" TRUE
229+
SF-TOGGLE "Extra Darkening" FALSE
230+
)
231+
232+
(script-fu-menu-register "elsamuko-deep-color" "<Toolbox>/Script-Fu/Artistic")
233+
234+
;end of script

0 commit comments

Comments
 (0)