Skip to content

Instantly share code, notes, and snippets.

@endavid
Created December 18, 2019 17:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endavid/fceea065e586052de944ffc57014692c to your computer and use it in GitHub Desktop.
Save endavid/fceea065e586052de944ffc57014692c to your computer and use it in GitHub Desktop.
Multilayered PSD from a list of images using #Gimp
;; 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)
)
)
@endavid
Copy link
Author

endavid commented May 24, 2022

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