-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathstack.scm
62 lines (56 loc) · 2.12 KB
/
stack.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
;; stack.scm: Make an averaged image stack:
;; combine all the layers with opacity 1/num_images.
;; Copyright (C) 2007 by Akkana Peck, [email protected].
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License.
(define (script-fu-stack-average img drawable)
(let* ((layers (gimp-image-get-layers img))
(numlayers (car layers))
(layer-array (cadr layers))
(i 0)
)
(gimp-message "Stacking")
(gimp-image-undo-group-start img)
;(gimp-context-push)
;; Loop over the layers.
;; Layers are numbered starting with 0 as the top layer in the stack.
(while (< i numlayers)
(gimp-message (number->string i))
(let* ((thislayer (aref layer-array i)))
(gimp-layer-set-opacity thislayer (* 100 (/ 1 (- numlayers i))))
)
(set! i (+ i 1))
)
;(gimp-message "")
;(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush)
) ; close let
)
(if (symbol-bound? 'script-fu-menu-register (the-environment))
(begin
(script-fu-register "script-fu-stack-average"
_"Stack (Average)..."
_"Set all layers' opacity to 1/N"
"Akkana Peck"
"Akkana Peck"
"January 2008"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-stack-average"
_"<Image>/Filters/Combine")
) ; end begin
(script-fu-register "script-fu-stack-average"
_"<Image>/Filters/Combine/Stack (Average)..."
_"Line up layers as a panorama"
"Akkana Peck"
"Akkana Peck"
"January 2008"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
)