|
| 1 | +;----------script-fu-set-all-layers-invisible---------- |
| 2 | +;procedure by Hevan53 |
| 3 | +;------------------------------------------------------ |
| 4 | + |
| 5 | +(define (script-fu-set-all-layers-invisible inImage inDrawable) |
| 6 | + (let* ( |
| 7 | + (layers (gimp-image-get-layers inImage)) |
| 8 | + (num-layers (car layers)) |
| 9 | + (layer-array (cadr layers)) |
| 10 | + (theLayer) |
| 11 | + ) |
| 12 | + |
| 13 | + (gimp-image-undo-group-start inImage) |
| 14 | + |
| 15 | + (while (> num-layers 0) |
| 16 | + (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) |
| 20 | + ) |
| 21 | + ) |
| 22 | + |
| 23 | + (gimp-image-undo-group-end inImage) |
| 24 | + (gimp-displays-flush) |
| 25 | + |
| 26 | + ) |
| 27 | +) |
| 28 | + |
| 29 | +;--------------------save-layers----------------------- |
| 30 | +;procedure by planetmaker |
| 31 | +; |
| 32 | +; // List of source and target images followed by a list of layer names |
| 33 | +; // in the source image which will make up the target image. |
| 34 | +; |
| 35 | +; // Example: |
| 36 | +; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...)) |
| 37 | +;------------------------------------------------------ |
| 38 | +(define |
| 39 | + ( |
| 40 | + save-layers |
| 41 | + |
| 42 | + inImageName |
| 43 | + outImageName |
| 44 | + inLayerNames |
| 45 | + ) |
| 46 | + (let* |
| 47 | + ( |
| 48 | + (image (car (gimp-file-load RUN-NONINTERACTIVE inImageName inImageName))) |
| 49 | + (visibleStuff (car (gimp-image-get-active-layer image))) |
| 50 | + (layers (gimp-image-get-layers image)) |
| 51 | + (num-layers (car layers)) |
| 52 | + (layer-array (cadr layers)) |
| 53 | + (thisLayer -1) |
| 54 | + (thisNumLayers 0) |
| 55 | + (theseLayers layers) |
| 56 | + (thisLayerName 0) |
| 57 | + |
| 58 | + (layerNames inLayerNames) |
| 59 | + ) |
| 60 | + |
| 61 | + ; First make everything invisble |
| 62 | + (script-fu-set-all-layers-invisible image image) |
| 63 | + |
| 64 | + ; Now make those layers visible which were asked to become visible |
| 65 | + |
| 66 | + ; iterate through all layers of the image |
| 67 | + (while (> num-layers 0) |
| 68 | + (set! num-layers (- num-layers 1)) |
| 69 | + (set! thisLayer (aref layer-array num-layers)) |
| 70 | + (set! thisLayerName (car (gimp-drawable-get-name thisLayer))) |
| 71 | + ; (gimp-message (string-append "Image Layer-Name: " thisLayerName)) |
| 72 | + |
| 73 | + ; iterate through all layer Names we shall use |
| 74 | + (set! layerNames inLayerNames) |
| 75 | + (while (not (null? layerNames)) |
| 76 | + ; if layerName matches this user supplied layername: make it visible |
| 77 | + (if (string=? (car layerNames) thisLayerName) |
| 78 | + (gimp-drawable-set-visible thisLayer TRUE) |
| 79 | + ) |
| 80 | + (set! layerNames (cdr layerNames)) |
| 81 | + ) |
| 82 | + ) |
| 83 | + |
| 84 | + ; Merge all visible layers into one layer which we then save to the given filename |
| 85 | + (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) |
| 87 | + (gimp-image-delete image) |
| 88 | + ) |
| 89 | +) |
| 90 | + |
| 91 | + |
| 92 | +; // =================================================================== |
| 93 | +; // List of source and target images followed by a list of layer names |
| 94 | +; // in the source image which will make up the target image. |
| 95 | +; // Example: |
| 96 | +; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...)) |
| 97 | +; // =================================================================== |
0 commit comments