Created
February 14, 2020 14:58
-
-
Save sudo-give-me-coffee/6ffef1829a9e1f54700a3c47e80bbdbb to your computer and use it in GitHub Desktop.
This snippet demonstrates how to interact with each layer in GIMP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (for-each-layer image drawable) | |
| (let* ( | |
| (layers (gimp-image-get-layers image)) ; The list of all layers of image | |
| (all-layers (cadr layers)) ; The list of all layers | |
| (count-layers (- (car layers) 1)) ; The number of layers contained in the image -1 (scheme is zero indexed) | |
| ) | |
| (gimp-image-undo-group-start image) | |
| (while (>= count-layers 0) | |
| (let ((current-layer (aref all-layers count-layers))) ; Catches current layer | |
| ; Do your work with "current-layer" | |
| (set! count-layers (- count-layers 1))) | |
| ) | |
| (gimp-image-undo-group-end image) | |
| (gimp-displays-flush) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment