-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFU_edges_photo-border-fancy.scm
175 lines (167 loc) · 6.7 KB
/
FU_edges_photo-border-fancy.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
; FU_edges_photo-border-fancy.scm
; version 2.8 [gimphelp.org]
; 2nd last modified/tested by Paul Sherman
; 02/14/2014 on GIMP-2.8.10
;
; recent updates:
; convert to RGB if needed, option to merge layer upon script completion
; last modified/tested by karlhof26
; 05/29/2020 on GIMP-2.10.18
; 11/07/2022 on Gimp 2.10.32 (US style date format)
;;==============================================================
;
; 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-photo-border
image
photo-layer
border
lower
shadow
border-color
border-shading-feather
border-shading-transparency
border-shading-color
text-string
text-font
text-height
text-color
inFlatten
)
(let* (
(w (car (gimp-image-width image)))
(h (car (gimp-image-height image)))
(th (/ (* h text-height) 100))
(bw (/ (* w border) 100))
(lh (/ (* w lower) 100))
(sw (/ (* w shadow) 100))
(bsw (/ (* w border) 400))
(bsf (/ (* w border-shading-feather) 100))
(with-border-width (+ bw (+ w bw)))
(with-border-height (+ bw (+ h (+ bw lh))))
(text-layer #f)
(border-shading-layer #f)
(border-layer 0)
)
; (gimp-context-push)
(gimp-image-undo-group-start image)
(if (not (= RGB (car (gimp-image-base-type image))))
(gimp-image-convert-rgb image)
)
(gimp-layer-add-alpha photo-layer)
;make room for border
(gimp-image-resize image with-border-width with-border-height bw bw)
(set! border-layer (car
(gimp-layer-new image with-border-width with-border-height 0 "Photo-Border" 100 LAYER-MODE-NORMAL)
))
(gimp-image-insert-layer image border-layer 0 1)
(gimp-context-set-foreground border-color)
(gimp-drawable-fill border-layer FILL-FOREGROUND)
(unless (= border-shading-feather 0)
(set! border-shading-layer (car
(gimp-layer-new image with-border-width with-border-height 0 "Photo-Border-Shadow"
border-shading-transparency LAYER-MODE-NORMAL)
)
)
(gimp-image-insert-layer image border-shading-layer 0 -1)
(gimp-context-set-foreground border-shading-color)
(gimp-drawable-fill border-shading-layer 0)
(gimp-image-set-active-layer image border-shading-layer)
(gimp-image-select-rectangle image CHANNEL-OP-REPLACE bsw bsw
(- with-border-width (* 2 bsw)) (- with-border-height (* 2 bsw)))
(gimp-edit-clear border-shading-layer)
(gimp-selection-none image)
(gimp-image-set-active-layer image photo-layer)
)
(unless (= lh 0)
; Polaroid style has shadow around frame (not in the same plane)
(script-fu-drop-shadow image photo-layer 0 0 (/ bw 5) '(0 0 0) 80 1)
)
(unless (= sw 0)
(script-fu-drop-shadow image border-layer (/ sw 4) (/ sw 4) sw '(0 0 0) 80 1)
)
(unless (= (string-length text-string) 0)
(gimp-context-set-foreground text-color)
(set! text-layer
(gimp-text-fontname image border-layer (* bw 1.2) (+ bw h (/ (- (+ bw lh) th) 2)) text-string 0 TRUE th PIXELS text-font) ; (/ (- (+ bw lh) th) 1.5)
)
)
(if (= inFlatten TRUE)
(begin
(gimp-image-flatten image)
)
)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)
(script-fu-register
"FU-photo-border"
"<Toolbox>/Script-Fu/Edges/Photo Border Fancy"
"Add white border to photo.\n
The extra lower border is for a 'Polaroid' effect,
in which case a caption may also be added.\n
A drop shadow further adds the effect
of a photo placed on a background.
\nfile:FU_edges_photo-border-fancy.scm
"
"Egil Kvaleberg"
"copyright 2009, Egil Kvaleberg"
"4 May, 2009"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-ADJUSTMENT "Border (%)" '(7.0 0 20 0.1 1.0 1 0)
SF-ADJUSTMENT "Extra Lower Border (0 for none) (%)" '(13.0 0 100 0.1 1.0 1 0)
SF-ADJUSTMENT "Drop Shadow (0 to disable) (%)" '(3.0 0 50 0.1 1.0 1 0)
SF-COLOR "Border Color" '(250 250 240)
SF-ADJUSTMENT "Border Shading Feather (0 for none) (%)" '(10.0 0 50 0.1 1.0 1 0)
SF-ADJUSTMENT "Border Shading Transparency (%)" '(12.0 0 100 0.5 5.0 1 0)
SF-COLOR "Border Shading Color" '(0 0 0)
SF-STRING "Caption Text (needs lower border)" "(Your Caption text here)"
SF-FONT "Caption Font" "Serif Bold"
;SF-FONT "Caption Font" (if (= 0 (car (gimp-fonts-get-list "Comic"))) "Serif Bold" (caadr (gimp-fonts-get-list "Comic")))
SF-ADJUSTMENT "Caption Height (%)" '(7.0 0 50 0.1 1.0 1 0)
SF-COLOR "Caption Text Color" '(220 70 70)
SF-TOGGLE "Flatten image when complete?" TRUE
)
; end of script