Last active
September 3, 2018 20:38
-
-
Save emanchado/dd2e76a2ad4b0a53765ce2dfd10b31b0 to your computer and use it in GitHub Desktop.
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 Gimp script applies a pattern (by using the "Multiply" layer mode) to another image. | |
;; Both images should probably have the same dimensions. | |
;; | |
;; Save in your ~/.gimp-2.8/scripts directory. | |
;; You can call it as follows: | |
;; gimp -i -b '(batch-apply-pattern "pattern.png" "target.png" "output.png")' -b '(gimp-quit 0)' | |
(define (batch-apply-pattern pattern-path target-image-path final-path) | |
(let* ((target-image (car (gimp-file-load RUN-NONINTERACTIVE target-image-path target-image-path))) | |
(pattern-image (car (gimp-file-load RUN-NONINTERACTIVE pattern-path pattern-path)))) | |
(unless (= (car (gimp-image-base-type target-image)) RGB) | |
(gimp-image-convert-rgb target-image)) | |
(unless (= (car (gimp-image-base-type pattern-image)) RGB) | |
(gimp-image-convert-rgb pattern-image)) | |
(let* ((pattern-layer (car (gimp-layer-new-from-visible pattern-image target-image "Pattern")))) | |
(gimp-image-insert-layer target-image pattern-layer 0 0) | |
(gimp-layer-set-mode pattern-layer MULTIPLY-MODE) | |
(let* ((final-layer (car (gimp-image-merge-down target-image pattern-layer CLIP-TO-IMAGE)))) | |
(gimp-file-save RUN-NONINTERACTIVE target-image final-layer final-path final-path))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment