Created
December 18, 2019 17:30
-
-
Save endavid/fceea065e586052de944ffc57014692c to your computer and use it in GitHub Desktop.
Multilayered PSD from a list of images using #Gimp
This file contains 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
;; Copy to ~/Library/Application\ Support/GIMP/2.10/scripts/ | |
;; Ref. https://stackoverflow.com/a/24164916/1765629 | |
;; Usage example: | |
;; gimp -i -b '(layers-to-psd (list "Background.jpg" "A.png" "B.png") "compo.psd")' -b '(gimp-quit 0)' | |
;; | |
(define (layers-to-psd image-paths psd-path) | |
(define (add-layers image image-paths) | |
(when (not (null? image-paths)) | |
(let* | |
( | |
(img-path (car image-paths)) | |
(layer (car (gimp-file-load-layer RUN-NONINTERACTIVE image img-path))) | |
) | |
;; (display img-path) (newline) | |
(gimp-image-insert-layer image layer 0 -1) | |
(add-layers image (cdr image-paths)) | |
) | |
) | |
) | |
(let* | |
( | |
(base-path (car image-paths)) | |
(image (car (gimp-file-load RUN-NONINTERACTIVE base-path base-path))) | |
(drawable (car (gimp-image-get-active-layer image))) | |
) | |
;; (display base-path) (newline) | |
(add-layers image (cdr image-paths)) | |
;; LZW compression (1), MSB to LSB fill order (0) | |
(file-psd-save RUN-NONINTERACTIVE image drawable psd-path psd-path 1 0) | |
(gimp-image-delete image) | |
) | |
) |
hey I am trying to generate PSD through the same code, my batch commands are being executing successfully but I am unable to generate PSD as output file. Kindly help.
P.S - I am trying it in windows.
Do you get any error messages? I can't help you without any information. Although even if I had the info, I'm not very familiar with GIMP. You better post a question in Stack Overflow.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A variation if you want to create your own image with an arbitrary precision:
(the
add-layers
function stays the same as above)