Skip to content

Commit 0b0e2e6

Browse files
jayaddisonmatthijskooijman
authored andcommitted
Upgrade #94: [gimpscript] GIMP3 compatibility
* Remove implicit SIOD array accesses[1] * Migrate removed `drawable` API calls to `item` equivalents * Introduce TinyScheme `vector-ref` and `vector-length` calls * Migrate[2] from `get-active-layer` to `get-selected-layers` * Call `file-png-export` (instead of `save`) with named arguments Refs: - [1] https://www.gimp.org/docs/script-fu-update.html#carempty - [2] https://samjcreations.blogspot.com/2022/08/api-gimp-29912-script-fu.html
1 parent 39c35c7 commit 0b0e2e6

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

scripts/gimpscript

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
(define (script-fu-set-all-layers-invisible inImage inDrawable)
66
(let* (
77
(layers (gimp-image-get-layers inImage))
8-
(num-layers (car layers))
9-
(layer-array (cadr layers))
8+
(layer-array (car layers))
9+
(num-layers (vector-length layer-array))
1010
(theLayer)
1111
)
1212

1313
(gimp-image-undo-group-start inImage)
1414

1515
(while (> num-layers 0)
1616
(set! num-layers (- num-layers 1))
17-
(set! theLayer (aref layer-array num-layers))
18-
(if (= (car (gimp-drawable-get-visible theLayer) ) TRUE)
19-
(gimp-drawable-set-visible theLayer FALSE)
17+
(set! theLayer (vector-ref layer-array num-layers))
18+
(if (= (car (gimp-item-get-visible theLayer) ) TRUE)
19+
(gimp-item-set-visible theLayer FALSE)
2020
)
2121
)
2222

@@ -46,10 +46,10 @@
4646
(let*
4747
(
4848
(image (car (gimp-file-load RUN-NONINTERACTIVE inImageName inImageName)))
49-
(visibleStuff (car (gimp-image-get-active-layer image)))
49+
(visibleStuff (vector-ref (car (gimp-image-get-selected-layers image)) 0))
5050
(layers (gimp-image-get-layers image))
51-
(num-layers (car layers))
52-
(layer-array (cadr layers))
51+
(layer-array (car layers))
52+
(num-layers (vector-length layer-array))
5353
(thisLayer -1)
5454
(thisNumLayers 0)
5555
(theseLayers layers)
@@ -66,24 +66,24 @@
6666
; iterate through all layers of the image
6767
(while (> num-layers 0)
6868
(set! num-layers (- num-layers 1))
69-
(set! thisLayer (aref layer-array num-layers))
70-
(set! thisLayerName (car (gimp-drawable-get-name thisLayer)))
69+
(set! thisLayer (vector-ref layer-array num-layers))
70+
(set! thisLayerName (car (gimp-item-get-name thisLayer)))
7171
; (gimp-message (string-append "Image Layer-Name: " thisLayerName))
7272

7373
; iterate through all layer Names we shall use
7474
(set! layerNames inLayerNames)
7575
(while (not (null? layerNames))
7676
; if layerName matches this user supplied layername: make it visible
7777
(if (string=? (car layerNames) thisLayerName)
78-
(gimp-drawable-set-visible thisLayer TRUE)
78+
(gimp-item-set-visible thisLayer TRUE)
7979
)
8080
(set! layerNames (cdr layerNames))
8181
)
8282
)
8383

8484
; Merge all visible layers into one layer which we then save to the given filename
8585
(set! visibleStuff (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)))
86-
(file-png-save RUN-NONINTERACTIVE image visibleStuff outImageName outImageName 0 9 0 0 0 0 0)
86+
(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)
8787
(gimp-image-delete image)
8888
)
8989
)

0 commit comments

Comments
 (0)