Skip to content

Instantly share code, notes, and snippets.

@sudo-give-me-coffee
Created February 14, 2020 14:58
Show Gist options
  • Select an option

  • Save sudo-give-me-coffee/6ffef1829a9e1f54700a3c47e80bbdbb to your computer and use it in GitHub Desktop.

Select an option

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
(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