-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFU_edges_tasty-frame.scm
230 lines (211 loc) · 8.73 KB
/
FU_edges_tasty-frame.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
; FU_edges_tasty-frame.scm
; version 2.8 [gimphelp.org]
; last modified/tested by Paul Sherman
; 02/14/2014 on GIMP-2.8.10
; 03/09/2020 on GIMP-2.10.20
;
; 01/07/2008 - modified by Paul Sherman
; removed "data" input
; but added user-defined font sizes for Title and Signature
;
; 04/24/2008
; trapped errors if empty string passed for title/signature
; made title and signature separate options
; (with different size lower borders)
;
; fixed again (gimp-text-fontname-fontname -> gimp-text-fontname)
; for gimp 2.6 - 11/20/2008
;
; 02/14/2014 - convert to RGB if needed
;==============================================================
;
; 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
;
; NOT AVAILABLE
;==============================================================
(define (FU-tasty-frame
img
drawable
radius
blur
color
border
colorborder
colorbackground
title
colorletters
tit
titf
signat
sig
sigf
font)
(gimp-image-undo-group-start img)
(if (not (= RGB (car (gimp-image-base-type img))))
(gimp-image-convert-rgb img))
(let* (
(blur (abs blur))
(radius (abs radius))
(diam (* 2 radius))
(width (car (gimp-image-width img)))
(height (car (gimp-image-height img)))
(type (car (gimp-drawable-type-with-alpha drawable)))
(image img)
(main-layer (car (gimp-image-get-active-drawable image)))
)
; Add an alpha channel to the image
(gimp-layer-add-alpha main-layer)
(gimp-selection-none image)
(gimp-image-select-rectangle image CHANNEL-OP-ADD 0 0 radius radius)
(gimp-image-select-ellipse image CHANNEL-OP-SUBTRACT 0 0 diam diam)
(gimp-image-select-rectangle image CHANNEL-OP-ADD (- width radius) 0 radius radius)
(gimp-image-select-ellipse image CHANNEL-OP-SUBTRACT (- width diam) 0 diam diam)
(gimp-image-select-rectangle image CHANNEL-OP-ADD 0 (- height radius) radius radius)
(gimp-image-select-ellipse image CHANNEL-OP-SUBTRACT 0 (- height diam) diam diam)
(gimp-image-select-rectangle image CHANNEL-OP-ADD (- width radius) (- height radius) radius radius)
(gimp-image-select-ellipse image CHANNEL-OP-SUBTRACT (- width diam) (- height diam) diam diam)
(gimp-edit-clear main-layer)
(gimp-selection-none image)
(gimp-context-set-background color)
(set! width (+ (car (gimp-image-width image)) blur blur))
(set! height (+ (car (gimp-image-height image)) blur blur))
(gimp-image-resize image width height blur blur)
(let* (
(shadow-layer (car (gimp-layer-new image width height type "Shadow" 100 LAYER-MODE-NORMAL)))
)
(gimp-image-insert-layer image shadow-layer 0 -1)
(gimp-edit-clear shadow-layer)
(gimp-image-select-item image CHANNEL-OP-REPLACE main-layer)
(gimp-edit-fill shadow-layer BACKGROUND-FILL)
(gimp-selection-none image)
(plug-in-gauss-rle2 1 image shadow-layer blur blur)
; This mask is to change the color of the shadow afterwards
(gimp-layer-add-mask shadow-layer (car (gimp-layer-create-mask shadow-layer ADD-MASK-ALPHA-TRANSFER)))
)
(if (and (= signat TRUE)(> (string-length sig) 0))
(set! height (+ height 18))
)
(if (and (= title TRUE)(> (string-length tit) 0))
(set! height (+ height 32))
)
(gimp-image-resize image width height 0 0)
(gimp-context-set-background colorbackground)
(let* (
(bg-layer (car (gimp-layer-new image width height type "Background" 100 LAYER-MODE-NORMAL)))
)
(gimp-drawable-fill bg-layer FILL-BACKGROUND)
(gimp-image-insert-layer image bg-layer 0 -1)
(gimp-image-raise-item image main-layer)
(gimp-image-lower-item image bg-layer)
(gimp-image-lower-item image bg-layer)
)
(gimp-context-set-foreground colorletters)
(if (and (= title TRUE) (> (string-length tit) 0))
(begin
(let* (
; Title
(title-layer (car (gimp-text-fontname image -1 0 0 tit 0 TRUE titf PIXELS font)))
(tw (car (gimp-drawable-width title-layer)))
(th (car (gimp-drawable-height title-layer)))
)
(gimp-layer-set-offsets title-layer (+ border blur) (- height (+ th border)))
(gimp-context-set-foreground '(255 255 255))
)
)
)
(if (and (= signat TRUE) (> (string-length sig) 0))
(begin
(let* (
; Signature
;(if (> (string-length sig) 0)
(signature-layer (car (gimp-text-fontname image -1 0 0 sig 0 TRUE sigf PIXELS font)))
(tw1 (car (gimp-drawable-width signature-layer)))
(th1 (car (gimp-drawable-height signature-layer)))
;)
)
;(if (defined? 'title-layer)(gimp-layer-set-offsets title-layer (+ border blur) (- height (+ th border))))
(gimp-layer-set-offsets signature-layer (- width (+ tw1 border blur)) (- height (+ th1 border)))
(gimp-context-set-foreground '(255 255 255))
)
)
)
(set! height (+ height (* 2 border)))
(set! width (+ width (* 2 border)))
(gimp-image-resize image width height border border)
(gimp-context-set-background colorborder)
(let* (
(bg-layer1 (car (gimp-layer-new image width height type "Border" 100 LAYER-MODE-NORMAL)))
)
(gimp-drawable-fill bg-layer1 FILL-BACKGROUND)
(gimp-image-insert-layer image bg-layer1 0 -1)
(gimp-image-lower-item-to-bottom image bg-layer1)
)
(gimp-context-set-background '(0 0 0))
(gimp-context-set-foreground '(255 255 255))
(gimp-image-flatten image)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)
(script-fu-register "FU-tasty-frame"
"<Toolbox>/Script-Fu/Edges/Tasty Frame - optional Title"
"Add a tasty frame to the image, including Title and name if desired. \nfile:FU_edges_tasty-frame.scm"
"Luis A. Florit <[email protected]>"
"Luis A. Florit"
"2007/06/03"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "Round edge radius" '(5 0 300 1 5 0 1)
SF-ADJUSTMENT "Light radius" '(13 0 300 1 5 0 1)
SF-COLOR "Light color" '(255 255 0)
SF-ADJUSTMENT "Border radius" '(3 0 300 1 1 0 1)
SF-COLOR "Border color" '(200 200 0)
SF-COLOR "Background color" '(0 0 0)
SF-TOGGLE "Add title" TRUE
SF-COLOR "Letter color" '(140 140 140)
SF-STRING "Title" "(Picture Title here)"
SF-ADJUSTMENT "Title Font" '(32 8 48 1 1 0 0)
SF-TOGGLE "Add signature" TRUE
SF-STRING "Signature" "(Your Name Here)"
SF-ADJUSTMENT "Signature Font" '(16 8 32 1 1 0 0)
SF-FONT "Font" "sans"
)
; end of script