-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wrought Iron-partial299.scm
651 lines (575 loc) · 24 KB
/
Wrought Iron-partial299.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
;Modernized with ModernizeMatic8 for Gimp 2.10.28 by vitforlinux.wordpress.com - dont remove
; Wrought Iron rel 0.01
; Created by Graechan
; Comments directed to http://gimpchat.com or http://gimpscripts.com
;
; License: GPLv3
; 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.
;
; To view a copy of the GNU General Public License
; visit: http://www.gnu.org/licenses/gpl.html
;
;
; ------------
;| Change Log |
; ------------
; Rel 0.01 - Initial Release
; Rel 0.02 - Little fix for gimp 2.10.32
; Fix code for gimp 2.99.6 working in 2.10
(cond ((not (defined? 'gimp-drawable-get-width)) (define gimp-drawable-get-width gimp-drawable-width)))
(cond ((not (defined? 'gimp-drawable-get-height)) (define gimp-drawable-get-height gimp-drawable-height)))
(cond ((not (defined? 'gimp-drawable-get-offsets)) (define gimp-drawable-get-offsets gimp-drawable-offsets)))
(cond ((not (defined? 'gimp-image-get-width)) (define gimp-image-get-width gimp-image-width)))
(cond ((not (defined? 'gimp-image-get-height)) (define gimp-image-get-height gimp-image-height)))
(cond ((not (defined? 'gimp-image-get-selected-drawables)) (define gimp-image-get-selected-drawables gimp-image-get-active-drawable)))
;
(define (script-fu-wrought-iron image drawable
iron-size
spread
bev-w
bev-d
brightness
contrast
outline
bkg-fill
bkg-color
frame
frame-size
gradient
keep-selection-in
conserve)
(let* (
(image-layer (car (gimp-image-get-active-layer image)))
(width (car (gimp-image-get-width image)))
(height (car (gimp-image-get-height image)))
(alpha (car (gimp-drawable-has-alpha image-layer)))
(sel (car (gimp-selection-is-empty image)))
(layer-name (car (gimp-item-get-name image-layer)))
(keep-selection keep-selection-in)
(selection-channel 0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(age-layer 0)
(bkg-layer 0)
)
(gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-context-set-default-colors)
(if (= alpha FALSE) (gimp-layer-add-alpha image-layer))
;;;;check that a selection was made if not make one
(if (= sel TRUE) (set! keep-selection FALSE))
(if (= sel TRUE) (gimp-image-select-item image 2 image-layer))
;;;;create selection-channel (gimp-selection-load selection-channel)
(gimp-selection-save image)
(set! selection-channel (car (gimp-image-get-selected-drawables image)))
(gimp-channel-set-opacity selection-channel 100)
(gimp-item-set-name selection-channel "selection-channel")
(gimp-image-set-active-layer image image-layer)
(gimp-drawable-edit-fill image-layer FILL-FOREGROUND)
;;;;begin the script
(if (= outline FALSE) (begin
(gimp-selection-invert image)
(gimp-drawable-edit-clear image-layer)
(gimp-selection-invert image)
(gimp-selection-shrink image iron-size)
(gimp-drawable-edit-clear image-layer)
(gimp-image-select-item image 2 image-layer)))
;;;;create the age-layer layer
(set! age-layer (car (gimp-layer-new image width height RGBA-IMAGE "Aging-Layer" 100 LAYER-MODE-SCREEN-LEGACY)))
(gimp-image-insert-layer image age-layer 0 -1)
(gimp-image-select-rectangle image 0 0 0 1 1)
(plug-in-solid-noise 1 image age-layer FALSE FALSE 0 1 4 4)
(plug-in-spread 1 image age-layer spread (/ spread 9))
(plug-in-gauss-rle2 1 image age-layer 5 5)
(plug-in-bump-map 1 image age-layer age-layer 108 83 50 0 0 0 0 TRUE FALSE 2)
(gimp-image-select-rectangle image 1 0 0 1 1)
(gimp-curves-spline age-layer 0 12 #(0 0 30 68 69 73 128 184 186 188 255 255))
(set! image-layer (car (gimp-image-merge-down image age-layer 0)))
(the-wrought-iron-beveller image image-layer 18 0 0 bev-w 0 0 135 30 bev-d 3 10 FALSE)
(set! image-layer (car (gimp-image-merge-down image (car (gimp-image-get-active-layer image)) 0)))
(gimp-curves-spline image-layer 0 22 #(0 0 21 138 37 222 62 255 83 230 106 166 147 87 173 63 199 90 223 160 255 255))
(gimp-brightness-contrast image-layer brightness contrast)
;;;;create the background layer
(set! bkg-layer (car (gimp-layer-new image width height RGBA-IMAGE "Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image bkg-layer 0 1)
(gimp-context-set-background bkg-color)
(if (= bkg-fill TRUE) (gimp-drawable-fill bkg-layer FILL-BACKGROUND))
;;;;create the frame
(if (= frame TRUE) (begin
(the-wrought-iron-frame image bkg-layer
frame-size ;xsize
frame-size ;ysize
gradient
FALSE ;reverse
FALSE ;tint
'(169 134 41) ;tint-color
FALSE ;use-pattern
"Crack" ;pattern
FALSE ;lomo
100 ;lomo-size
80 ;lomo-opacity
FALSE ;keep-selection-in
FALSE))) ;conserve
;;;;finish the script
(if (= conserve FALSE) (set! image-layer (car (gimp-image-merge-down image image-layer EXPAND-AS-NECESSARY))))
(gimp-item-set-name image-layer layer-name)
(if (= keep-selection TRUE) (gimp-selection-load selection-channel))
(gimp-image-remove-channel image selection-channel)
(if (and (= conserve FALSE) (= alpha FALSE) (gimp-layer-flatten image-layer)))
(gimp-displays-flush)
(gimp-image-undo-group-end image)
(gimp-context-pop)
)
)
(script-fu-register "script-fu-wrought-iron"
"Wrought Iron..."
"Wrought Iron can Create shapes with the texture and look of wrought-iron work with optional frame and bkg color"
"Graechan"
"Graechan - http://gimpchat.com"
"Dec 2012"
"RGB*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
SF-ADJUSTMENT "Wrought-Iron Width" '(20 1 30 1 10 0 0)
SF-ADJUSTMENT "Pitting Amount" '(100 0 200 1 10 0 0)
SF-ADJUSTMENT "Bevel Width" '(5 1 100 1 10 0 0)
SF-ADJUSTMENT "Bevel Depth" '(3 1 60 1 10 0 0)
SF-ADJUSTMENT "Brightness" '(-50 -127 127 1 10 0 0)
SF-ADJUSTMENT "Contrast" '(30 -127 127 1 10 0 0)
SF-TOGGLE "Use full Image not just Outline" FALSE
SF-TOGGLE "Apply Bkg-Color" FALSE
SF-COLOR "Background color" '(153 153 153)
SF-TOGGLE "Apply a Frame" FALSE
SF-ADJUSTMENT "Frame-Size" '(50 1 250 1 10 0 0)
SF-GRADIENT "Border Gradient" "Crown molding"
SF-TOGGLE "Keep selection" FALSE
SF-TOGGLE "Keep the Layers" FALSE
)
(script-fu-menu-register "script-fu-wrought-iron" "<Image>/Script-Fu/Alpha-to-Logo/")
(define (script-fu-wrought-iron-logo
text
font-in
font-size
spread
bev-w
bev-d
brightness
contrast
bkg-fill
bkg-color
frame
frame-size
gradient
conserve)
(let* (
(image (car (gimp-image-new 256 256 RGB)))
(border (/ font-size 3))
(font (if (> (string-length font-in) 0) font-in (car (gimp-context-get-font))))
(size-layer (car (gimp-text-fontname image -1 0 0 text border TRUE font-size PIXELS font)))
(final-width (car (gimp-drawable-get-width size-layer)))
(final-height (car (gimp-drawable-get-height size-layer)))
(text-layer 0)
(width 0)
(height 0)
(iron-size 20)
(outline TRUE)
(bkg-layer 0)
)
(gimp-context-push)
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
;;;;Add the text layer for a temporary larger Image size
(set! text-layer (car (gimp-text-fontname image -1 0 0 text (round (/ 350 3)) TRUE 350 PIXELS font)))
(set! width (car (gimp-drawable-get-width text-layer)))
(set! height (car (gimp-drawable-get-height text-layer)))
(gimp-image-remove-layer image size-layer)
(gimp-image-resize-to-layers image)
;;;;centre text on line
(gimp-text-layer-set-justification text-layer 2)
;;;;set the text clolor
(gimp-image-select-item image 2 text-layer)
(gimp-drawable-edit-fill text-layer FILL-FOREGROUND)
;;;;Start the script;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(script-fu-wrought-iron image
text-layer
iron-size
spread
bev-w
bev-d
brightness
contrast
outline
bkg-fill
bkg-color
FALSE ;frame
frame-size
gradient
FALSE ;keep-selection-in
TRUE) ;conserve
(set! bkg-layer (car (gimp-image-get-active-layer image)))
;;;;Scale Image to it's original size;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(gimp-image-scale-full image final-width final-height 2)
(set! width (car (gimp-image-get-width image)))
(set! height (car (gimp-image-get-height image)))
(if (= frame TRUE) (begin
(the-wrought-iron-frame image bkg-layer
frame-size ;xsize
frame-size ;ysize
gradient
FALSE ;reverse
FALSE ;tint
'(169 134 41) ;tint-color
FALSE ;use-pattern
"Crack" ;pattern
FALSE ;lomo
100 ;lomo-size
80 ;lomo-opacity
FALSE ;keep-selection-in
FALSE))) ;conserve
(if (= conserve FALSE) (begin
(set! text-layer (car (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY)))
(gimp-item-set-name text-layer text)))
(gimp-context-pop)
(gimp-display-new image)
)
)
(script-fu-register "script-fu-wrought-iron-logo"
"Wrought Iron Logo..."
"Wrought Iron can Create Logos with the texture and look of wrought-iron work with optional frame and bkg color"
"Graechan"
"Graechan - http://gimpchat.com"
"Dec 2012"
""
SF-TEXT "Text" "Wrought Iron"
SF-FONT "Font" "JasmineUPC Bold"
SF-ADJUSTMENT "Font size (pixels)" '(150 50 600 1 10 0 1)
SF-ADJUSTMENT "Pitting Amount" '(100 0 200 1 10 0 0)
SF-ADJUSTMENT "Bevel Width" '(5 1 100 1 10 0 0)
SF-ADJUSTMENT "Bevel Depth" '(3 1 60 1 10 0 0)
SF-ADJUSTMENT "Brightness" '(-50 -127 127 1 10 0 0)
SF-ADJUSTMENT "Contrast" '(30 -127 127 1 10 0 0)
SF-TOGGLE "Apply Bkg-Color" FALSE
SF-COLOR "Background color" '(153 153 153)
SF-TOGGLE "Apply a Frame" FALSE
SF-ADJUSTMENT "Frame-Size" '(50 1 250 1 10 0 0)
SF-GRADIENT "Border Gradient" "Crown molding"
SF-TOGGLE "Keep the Layers" FALSE
)
(script-fu-menu-register "script-fu-wrought-iron-logo" "<Image>/Script-Fu/Logos/")
(define (the-wrought-iron-beveller image drawable
layer-mode
bev-type
bev-dir
bev-width
shape
prenoise
light-angle
light-elevation
depth
postblur
gloss
keep-selection-in)
(let* (
(image-layer (car (gimp-image-get-active-layer image)))
(width (car (gimp-image-get-width image)))
(height (car (gimp-image-get-height image)))
(alpha (car (gimp-drawable-has-alpha image-layer)))
(image-channel 0)
(bevel-layer 0)
(name 0)
(*newpoint* (cons-array 6 'double))
(*newpointx1* (cons-array 16 'double))
(y1 0)
(y2 0)
(y3 0)
(y4 0)
(y5 0)
(y6 0)
(keep-selection keep-selection-in)
(selection-bounds 0)
(bounds-x1 0)
(bounds-y1 0)
(bounds-x2 0)
(bounds-y2 0)
)
(gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
(if (= alpha FALSE) (gimp-layer-add-alpha image-layer))
;;;;check that a selection was made if not make one
(if (= (car (gimp-selection-is-empty image)) TRUE) (set! keep-selection FALSE))
(if (= (car (gimp-selection-is-empty image)) TRUE) (gimp-image-select-item image 2 image-layer))
;;;;find the selection co-ordinates
(set! selection-bounds (cdr (gimp-selection-bounds image)))
(set! bounds-x1 (car selection-bounds));x coordinate of upper left corner of selection bounds
(set! bounds-y1 (cadr selection-bounds));y coordinate of upper left corner of selection bounds
(set! bounds-x2 (caddr selection-bounds));x coordinate of lower right corner of selection bounds
(set! bounds-y2 (cadddr selection-bounds));y coordinate of lower right corner of selection bounds
;;;;This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).
;;;;save the selection
(gimp-selection-save image)
(set! image-channel (car (gimp-image-get-selected-drawables image)))
(gimp-channel-set-opacity image-channel 100)
(gimp-item-set-name image-channel "image-channel")
(gimp-image-set-active-layer image image-layer)
;;;;Add new layer with Bevel
(if (= bev-type 0) (set! name "Inner bevel"))
(if (= bev-type 1) (set! name "Outer bevel"))
(gimp-selection-load image-channel)
(gimp-image-set-active-layer image image-layer)
(set! bevel-layer (car (gimp-layer-new image width height RGBA-IMAGE name 100 layer-mode)))
(gimp-image-insert-layer image bevel-layer 0 -1)
(gimp-image-set-active-layer image bevel-layer)
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
;(if (> grow 0) (gimp-selection-grow image grow));;;;Expand the selection if needed
(gimp-drawable-fill bevel-layer FILL-FOREGROUND)
(gimp-selection-shrink image 1)
(gimp-selection-feather image bev-width)
(if (= bev-type 0) (gimp-selection-shrink image (- (/ bev-width 2) 1)))
(if (= bev-type 1) (gimp-selection-grow image (+ (/ bev-width 2) 1)))
(gimp-drawable-edit-fill bevel-layer FILL-BACKGROUND)
;;;;apply shape curve
(if (or (< shape 0) (> shape 0))
(begin
(aset *newpoint* 0 0) ; set the arrays
(aset *newpoint* 1 0)
(aset *newpoint* 2 (round (+ (/ shape 10) 127)))
(aset *newpoint* 3 (+ shape 127))
(aset *newpoint* 4 255)
(aset *newpoint* 5 255)
(gimp-curves-spline bevel-layer 0 6 *newpoint*)
)
)
(gimp-selection-all image)
;;;;invert colours of whole layer if down
(if (= bev-dir 1) (gimp-invert bevel-layer))
;;;;add prenoise
(if (> prenoise 0) (plug-in-hsv-noise 1 image bevel-layer 4 0 0 prenoise))
;;;;emboss the selection
(plug-in-emboss RUN-NONINTERACTIVE image bevel-layer light-angle light-elevation depth 1);Emboss
;;;;gloss the bevel-layer
(if (> gloss 0)
(begin
(set! y1 (* 1.0 gloss))
(set! y2 (* 3.0 gloss))
(set! y3 (* 9.6 gloss))
(set! y4 (* 3.2 gloss))
(set! y5 (* 4.0 gloss))
(set! y6 (* 0.4 gloss))
(aset *newpointx1* 0 0) ; set the arrays
(aset *newpointx1* 1 0)
(aset *newpointx1* 2 63)
(aset *newpointx1* 3 (+ 63 y1))
(aset *newpointx1* 4 95)
(aset *newpointx1* 5 (+ 95 y2))
(aset *newpointx1* 6 127)
(aset *newpointx1* 7 (- 127 y3))
(aset *newpointx1* 8 156)
(aset *newpointx1* 9 (+ 156 y4))
(aset *newpointx1* 10 191)
(aset *newpointx1* 11 (- 191 y5))
(aset *newpointx1* 12 223)
(aset *newpointx1* 13 (+ 223 y6))
(aset *newpointx1* 14 255)
(aset *newpointx1* 15 255)
;(0,0, 63,(63 + y1), 95,(95 + y2), 127,(127 - y3), 156,(156 + y4), 191,(191 - y5), 223,(223 + y6), 255,255)
(gimp-curves-spline bevel-layer 0 16 *newpointx1*)
)
)
(gimp-selection-load image-channel)
;postblur
(if (> postblur 0) (plug-in-gauss-rle2 RUN-NONINTERACTIVE image bevel-layer postblur postblur))
;(if (> postblur 0) (plug-in-gauss-rle 1 image bevel-layer postblur TRUE TRUE))
(gimp-layer-set-lock-alpha bevel-layer FALSE)
;reload selection
(gimp-selection-load image-channel)
;clear excess
(if (= bev-type 0)
(begin
(gimp-selection-shrink image 1)
(gimp-selection-invert image)
(gimp-drawable-edit-clear bevel-layer)
(gimp-selection-invert image)))
(if (= bev-type 1)
(begin
(gimp-selection-shrink image 1)
(gimp-drawable-edit-clear bevel-layer)))
;;;;Clean up the layers
(if (= keep-selection FALSE) (gimp-selection-none image))
(gimp-image-remove-channel image image-channel)
(if (= alpha FALSE) (gimp-layer-flatten image-layer))
(gimp-displays-flush)
(gimp-image-undo-group-end image)
(gimp-context-pop)
)
)
(define (the-wrought-iron-frame image drawable
xsize
ysize
gradient
reverse
tint
tint-color
use-pattern
pattern
lomo
lomo-size
lomo-opacity
keep-selection-in
conserve)
(let* (
(image-layer (car (gimp-image-get-active-layer image)))
(old-width (car (gimp-drawable-get-width image-layer)))
(old-height (car (gimp-drawable-get-height image-layer)))
(width (+ old-width (* xsize 2)))
(height (+ old-height (* ysize 2)))
(alpha (car (gimp-drawable-has-alpha image-layer)))
(typeA (car (gimp-drawable-type-with-alpha image-layer)))
(sel (car (gimp-selection-is-empty image)))
(layer-name (car (gimp-item-get-name image-layer)))
(keep-selection keep-selection-in)
(original-selection-channel 0)
(selection-channel 0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(border-layer 0)
(tint-layer 0)
(bump-layer 0)
(*newpoint-top* (cons-array 10 'double))
(*newpoint-bot* (cons-array 10 'double))
(*newpoint-left* (cons-array 10 'double))
(*newpoint-right* (cons-array 10 'double))
)
(gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-context-set-default-colors)
;;;;create original-selection-channel if a selection exists (gimp-selection-load original-selection-channel)
(if (= sel FALSE) (begin
(gimp-selection-save image)
(set! original-selection-channel (car (gimp-image-get-selected-drawables image)))
(gimp-channel-set-opacity original-selection-channel 100)
(gimp-item-set-name original-selection-channel "original-selection-channel")
(gimp-image-set-active-layer image image-layer)
(gimp-selection-none image)))
(if (= alpha FALSE) (gimp-layer-add-alpha image-layer))
;;;;create the Image selection
(gimp-rect-select image
(car (gimp-drawable-get-offsets image-layer))
(cadr (gimp-drawable-get-offsets image-layer))
old-width
old-height
CHANNEL-OP-REPLACE
FALSE
10)
;;;;create selection-channel (gimp-selection-load selection-channel)
(gimp-selection-save image)
(set! selection-channel (car (gimp-image-get-selected-drawables image)))
(gimp-channel-set-opacity selection-channel 100)
(gimp-item-set-name selection-channel "selection-channel")
(gimp-image-set-active-layer image image-layer)
(gimp-selection-none image)
;;;;begin the script
;;;;prepare for the border
(if (= lomo TRUE) (the-gradient-frame-vignette image image-layer lomo-size lomo-opacity FALSE FALSE))
(gimp-image-resize image width height xsize ysize)
(set! border-layer (car (gimp-layer-new image width height typeA "Border" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image border-layer 0 -1)
(if (= tint TRUE) (begin
(set! tint-layer (car (gimp-layer-new image width height typeA "Tint" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image tint-layer 0 1)
(gimp-context-set-background tint-color)
(gimp-selection-load selection-channel)
(gimp-selection-invert image)
(gimp-layer-set-mode border-layer GRAIN-MERGE-MODE)
(gimp-drawable-edit-fill tint-layer FILL-BACKGROUND)))
(gimp-image-set-active-layer image border-layer)
(set! bump-layer (car (gimp-layer-new image width height typeA "Grain" 100 LAYER-MODE-NORMAL-LEGACY)))
(gimp-image-insert-layer image bump-layer 0 -1)
(gimp-item-set-visible bump-layer FALSE)
(if (= use-pattern TRUE) (begin
(gimp-context-set-pattern pattern)
(gimp-drawable-edit-fill bump-layer FILL-PATTERN)
(gimp-desaturate bump-layer)))
(gimp-selection-none image)
(aset *newpoint-top* 0 0) ; set the top arrays
(aset *newpoint-top* 1 0)
(aset *newpoint-top* 2 xsize)
(aset *newpoint-top* 3 ysize)
(aset *newpoint-top* 4 (+ xsize old-width))
(aset *newpoint-top* 5 ysize)
(aset *newpoint-top* 6 width)
(aset *newpoint-top* 7 0)
(aset *newpoint-top* 8 0)
(aset *newpoint-top* 9 0)
(aset *newpoint-bot* 0 0) ; set the bottom arrays
(aset *newpoint-bot* 1 height)
(aset *newpoint-bot* 2 xsize)
(aset *newpoint-bot* 3 (+ ysize old-height))
(aset *newpoint-bot* 4 (+ xsize old-width))
(aset *newpoint-bot* 5 (+ ysize old-height))
(aset *newpoint-bot* 6 width)
(aset *newpoint-bot* 7 height)
(aset *newpoint-bot* 8 0)
(aset *newpoint-bot* 9 height)
(aset *newpoint-left* 0 0) ; set the left arrays
(aset *newpoint-left* 1 0)
(aset *newpoint-left* 2 xsize)
(aset *newpoint-left* 3 ysize)
(aset *newpoint-left* 4 xsize)
(aset *newpoint-left* 5 (+ ysize old-height))
(aset *newpoint-left* 6 0)
(aset *newpoint-left* 7 height)
(aset *newpoint-left* 8 0)
(aset *newpoint-left* 9 0)
(aset *newpoint-right* 0 width) ; set the right arrays
(aset *newpoint-right* 1 0)
(aset *newpoint-right* 2 (+ xsize old-width))
(aset *newpoint-right* 3 ysize)
(aset *newpoint-right* 4 (+ xsize old-width))
(aset *newpoint-right* 5 (+ ysize old-height))
(aset *newpoint-right* 6 width)
(aset *newpoint-right* 7 height)
(aset *newpoint-right* 8 width)
(aset *newpoint-right* 9 0)
(gimp-context-set-gradient gradient)
;;;;create the top of border
(gimp-free-select image 10 *newpoint-top* 2 TRUE FALSE 15)
(gimp-edit-blend border-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 REPEAT-NONE reverse FALSE 3 0.2 TRUE (/ width 2) 0 (/ width 2) ysize)
;;;;create the bottom of border
(gimp-free-select image 10 *newpoint-bot* 2 TRUE FALSE 15)
(gimp-edit-blend border-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 REPEAT-NONE reverse FALSE 3 0.2 TRUE (/ width 2) height (/ width 2) (+ old-height ysize))
;;;;create the left of border
(gimp-free-select image 10 *newpoint-left* 2 TRUE FALSE 15)
(gimp-edit-blend border-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 REPEAT-NONE reverse FALSE 3 0.2 TRUE 0 (/ height 2) xsize (/ height 2))
;;;;create the right of border
(gimp-free-select image 10 *newpoint-right* 2 TRUE FALSE 15)
(gimp-edit-blend border-layer BLEND-CUSTOM LAYER-MODE-NORMAL-LEGACY GRADIENT-LINEAR 100 0 REPEAT-NONE reverse FALSE 3 0.2 TRUE width (/ height 2) (+ old-width xsize) (/ height 2))
(gimp-selection-none image)
(gimp-image-set-active-layer image border-layer)
(if (= tint TRUE) (plug-in-sample-colorize 1 image border-layer tint-layer TRUE FALSE FALSE TRUE 0 255 1.00 0 255))
(if (= use-pattern TRUE) (plug-in-bump-map 1 image border-layer bump-layer 135 45 3 0 0 0 0 TRUE FALSE LINEAR))
;;;;finish the script
(if (= conserve FALSE) (begin
(set! border-layer (car (gimp-image-merge-down image border-layer EXPAND-AS-NECESSARY)))
;(set! image-layer (car (gimp-image-merge-down image border-layer EXPAND-AS-NECESSARY)))
(gimp-image-remove-layer image bump-layer)
; (gimp-item-set-name image-layer layer-name)
))
(if (and (= sel TRUE) (= keep-selection TRUE)) (gimp-selection-load selection-channel))
(if (and (= sel FALSE) (= keep-selection TRUE)) (gimp-selection-load original-selection-channel))
(gimp-image-remove-channel image selection-channel)
(if (= sel FALSE) (gimp-image-remove-channel image original-selection-channel))
(if (and (= conserve FALSE) (= alpha FALSE) (gimp-layer-flatten image-layer)))
(gimp-displays-flush)
(gimp-image-undo-group-end image)
(gimp-context-pop)
)
)