-
Notifications
You must be signed in to change notification settings - Fork 27
Script-Fu: Support GIMP3 in addition to GIMP2 #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
frosch123
merged 2 commits into
OpenTTD:master
from
matthijskooijman:issue-94/gimp3-scriptfu-compatibility
Mar 30, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| ;----------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)) | ||
| (num-layers (car layers)) | ||
| (layer-array (cadr layers)) | ||
| (theLayer) | ||
| ) | ||
|
|
||
| (gimp-image-undo-group-start inImage) | ||
|
|
||
| (while (> num-layers 0) | ||
| (set! num-layers (- num-layers 1)) | ||
| (set! theLayer (aref layer-array num-layers)) | ||
| (if (= (car (gimp-drawable-get-visible theLayer) ) TRUE) | ||
| (gimp-drawable-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))) | ||
| (visibleStuff (car (gimp-image-get-active-layer image))) | ||
| (layers (gimp-image-get-layers image)) | ||
| (num-layers (car layers)) | ||
| (layer-array (cadr layers)) | ||
| (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 (aref layer-array num-layers)) | ||
| (set! thisLayerName (car (gimp-drawable-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-drawable-set-visible thisLayer TRUE) | ||
| ) | ||
| (set! layerNames (cdr layerNames)) | ||
| ) | ||
| ) | ||
|
|
||
| ; Merge all visible layers into one layer which we then save to the given filename | ||
| (set! visibleStuff (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))) | ||
| (file-png-save RUN-NONINTERACTIVE image visibleStuff outImageName outImageName 0 9 0 0 0 0 0) | ||
| (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 ...)) | ||
| ; // =================================================================== |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.