File: elsamuko-cyanotype.scm

package info (click to toggle)
gimp-plugin-registry 7.20140602
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 55,856 kB
  • ctags: 4,984
  • sloc: ansic: 46,100; lisp: 20,560; python: 14,721; sh: 3,306; cpp: 2,528; makefile: 1,023; xml: 546
file content (155 lines) | stat: -rw-r--r-- 6,430 bytes parent folder | download | duplicates (7)
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
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; 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, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
; http://www.gnu.org/licenses/gpl-3.0.html
;
; Copyright (C) 2010 elsamuko <elsamuko@web.de>
;


(define (elsamuko-cyanotype aimg adraw
                            color1 color2
                            localcontrast 
                            overlay
                            blackwhite)
  (let* ((img (car (gimp-drawable-get-image adraw)))
         (owidth (car (gimp-image-width img)))
         (oheight (car (gimp-image-height img)))
         (tmplayer1 0)         
         (tmplayer2 0)         
         (contrastlayer 0)
         (bw-layer 0)
         (overlay-layer (car (gimp-layer-copy adraw FALSE)))
         (blue-layer (car (gimp-layer-new img
                                          owidth 
                                          oheight
                                          RGBA-IMAGE
                                          "Prussian Blue" 
                                          100 
                                          NORMAL-MODE)))
         (blue-mask (car (gimp-layer-create-mask blue-layer ADD-WHITE-MASK)))
         (white-layer (car (gimp-layer-new img
                                           owidth 
                                           oheight
                                           RGBA-IMAGE
                                           "Aged White" 
                                           100 
                                           NORMAL-MODE)))
         (white-mask (car (gimp-layer-create-mask white-layer ADD-WHITE-MASK)))
         (blue-overlay-layer (car (gimp-layer-new img
                                                  owidth 
                                                  oheight
                                                  RGBA-IMAGE
                                                  "Blue Overlay" 
                                                  80 
                                                  OVERLAY-MODE)))
         )
    
    ; init
    (gimp-context-push)
    (gimp-image-undo-group-start img)
    (if (= (car (gimp-drawable-is-gray adraw )) TRUE)
        (gimp-image-convert-rgb img)
        )
    
    ;desaturate original
    (if(= blackwhite TRUE)
       (begin
         (gimp-edit-copy-visible img)
         (set! bw-layer (car (gimp-layer-new-from-visible img img "B/W")))
         (gimp-image-add-layer img bw-layer -1)
         (gimp-desaturate-full bw-layer DESATURATE-LIGHTNESS)
         )
       )
    
    ;enhance local contrast
    (if(> localcontrast 0)
       (begin
         (gimp-edit-copy-visible img)
         (set! tmplayer1 (car (gimp-layer-new-from-visible img img "Temp 1")))
         (set! tmplayer2 (car (gimp-layer-new-from-visible img img "Temp 2")))
         (gimp-image-add-layer img tmplayer1 -1)
         (gimp-image-add-layer img tmplayer2 -1)
         (plug-in-unsharp-mask 1 img tmplayer1 60 localcontrast 0)
         (gimp-layer-set-mode tmplayer2 GRAIN-EXTRACT-MODE)
         (gimp-edit-copy-visible img)
         (set! contrastlayer (car (gimp-layer-new-from-visible img img "Local Contrast")))
         (gimp-image-add-layer img contrastlayer -1)
         (gimp-layer-set-mode contrastlayer GRAIN-MERGE-MODE)
         (gimp-image-remove-layer img tmplayer1)
         (gimp-image-remove-layer img tmplayer2)
         )
       )
    
    ;set blue and white layers
    (gimp-image-add-layer img blue-layer -1)
    (gimp-image-add-layer img white-layer -1)
    (gimp-selection-all aimg)
    (gimp-context-set-foreground color1)
    (gimp-edit-bucket-fill blue-layer FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
    (gimp-context-set-foreground color2)
    (gimp-edit-bucket-fill white-layer FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
    
    ;add layer masks
    (gimp-edit-copy adraw)
    (gimp-layer-add-mask blue-layer blue-mask)
    (gimp-floating-sel-anchor (car (gimp-edit-paste blue-mask TRUE)))
    (gimp-invert blue-mask)
    (gimp-layer-add-mask white-layer white-mask)
    (gimp-floating-sel-anchor (car (gimp-edit-paste white-mask TRUE)))
    
    ;set overlay layer
    (if(> overlay 0)
       (begin
         (gimp-image-add-layer img overlay-layer -1)
         (gimp-drawable-set-name overlay-layer "Overlay")
         (gimp-layer-set-mode overlay-layer OVERLAY-MODE)
         (gimp-layer-set-opacity overlay-layer overlay)
         (gimp-desaturate-full overlay-layer DESATURATE-LIGHTNESS)
         )
       )
    
    ;set blue overlay layer
    (gimp-image-add-layer img blue-overlay-layer -1)
    (gimp-selection-all aimg)
    (gimp-context-set-foreground color1)
    (gimp-edit-bucket-fill blue-overlay-layer FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
    (gimp-selection-none img)
    
    ; tidy up
    (gimp-image-undo-group-end img)
    (gimp-displays-flush)
    (gimp-context-pop)
    )
  )

(script-fu-register "elsamuko-cyanotype"
                    "_Cyanotype"
                    "Cyanotype effect from 1842."
                    "elsamuko <elsamuko@web.de>"
                    "elsamuko"
                    "14/03/10"
                    "RGB*"
                    SF-IMAGE       "Input image"          0
                    SF-DRAWABLE    "Input drawable"       0
                    SF-COLOR      _"Prussian Blue"       '( 61  87 136)
                    SF-COLOR      _"Aged White"          '(251 253 240)
                    SF-ADJUSTMENT _"Local Contrast"      '(0.4 0   2 0.1 0.2 1 0)
                    SF-ADJUSTMENT _"B/W Overlay"         '(50  0  100  1   5 0 0)                    
                    SF-TOGGLE     _"Desaturate Image"     TRUE
                    )

(script-fu-menu-register "elsamuko-cyanotype" _"<Image>/Filters/Artistic")