-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathgimpscript
More file actions
95 lines (80 loc) · 3.08 KB
/
gimpscript
File metadata and controls
95 lines (80 loc) · 3.08 KB
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
;----------script-fu-set-all-layers-invisible----------
;procedure by Hevan53
;------------------------------------------------------
(define (script-fu-set-all-layers-invisible inImage inDrawable)
(let* (
(layers (gimp-image-get-layers inImage))
(layer-array (car layers))
(num-layers (vector-length layer-array))
(theLayer)
)
(gimp-image-undo-group-start inImage)
(while (> num-layers 0)
(set! num-layers (- num-layers 1))
(set! theLayer (vector-ref layer-array num-layers))
(if (= (car (gimp-item-get-visible theLayer) ) TRUE)
(gimp-item-set-visible theLayer FALSE)
)
)
(gimp-image-undo-group-end inImage)
(gimp-displays-flush)
)
)
;--------------------save-layers-----------------------
;procedure by planetmaker
;
; // List of source and target images followed by a list of layer names
; // in the source image which will make up the target image.
;
; // Example:
; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...))
;------------------------------------------------------
(define
(
save-layers
inImageName
outImageName
inLayerNames
)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE inImageName inImageName)))
(layers (gimp-image-get-layers image))
(layer-array (car layers))
(num-layers (vector-length layer-array))
(thisLayer -1)
(thisNumLayers 0)
(theseLayers layers)
(thisLayerName 0)
(layerNames inLayerNames)
)
; First make everything invisble
(script-fu-set-all-layers-invisible image image)
; Now make those layers visible which were asked to become visible
; iterate through all layers of the image
(while (> num-layers 0)
(set! num-layers (- num-layers 1))
(set! thisLayer (vector-ref layer-array num-layers))
(set! thisLayerName (car (gimp-item-get-name thisLayer)))
; (gimp-message (string-append "Image Layer-Name: " thisLayerName))
; iterate through all layer Names we shall use
(set! layerNames inLayerNames)
(while (not (null? layerNames))
; if layerName matches this user supplied layername: make it visible
(if (string=? (car layerNames) thisLayerName)
(gimp-item-set-visible thisLayer TRUE)
)
(set! layerNames (cdr layerNames))
)
)
; Merge all visible layers into one layer which we then save to the given filename
(file-png-export #:run-mode RUN-NONINTERACTIVE #:image image #:file outImageName #:interlaced FALSE #:compression 9 #:bkgd FALSE #:offs FALSE #:phys FALSE #:time FALSE #:save-transparent FALSE)
(gimp-image-delete image)
)
)
; // ===================================================================
; // List of source and target images followed by a list of layer names
; // in the source image which will make up the target image.
; // Example:
; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...))
; // ===================================================================