I need to open a PSD image, write out the layers and get information about the masks. Am having problems recognizing a layer mask.
I've created a simple PSD image with one layer that has a layer mask. I can write out the layer and the background layer as separate jpgs, but this code does not recognize the layer mask.
Can anyone help?
(define (batch-process-psd-image-maskV2 in1)
;; to run: gimp -b "(batch-process-psd-image-maskV2 \"MaskTest\")"
(let*
(
(inExt (string-append in1 ".psd" ))
(image (car (gimp-file-load RUN-NONINTERACTIVE inExt inExt)))
)
(let* (
(layers (vector->list (cadr (gimp-image-get-layers image))) )
)
(while (not (null? layers))
(car (gimp-edit-copy (car layers ) ))
(let* (
(imgLayer (car (gimp-edit-paste-as-new)))
(layerName (car (gimp-drawable-get-name (car layers) ) ))
(jpgExt (string-append layerName "_LAYER.jpg" ))
(mskName (string-append layerName "_MASK.jpg" ))
(drwLayer(aref (cadr (gimp-image-get-layers imgLayer)) 0) )
)
(if (= TRUE (car ( gimp-drawable-is-layer-mask drwLayer ) ) )
(gimp-file-save RUN-NONINTERACTIVE imgLayer drwLayer mskName mskName )
)
(gimp-file-save RUN-NONINTERACTIVE imgLayer drwLayer jpgExt jpgExt)
(gimp-image-delete imgLayer) ;; clean up
) ;; let - layer info
(set! layers (cdr layers ))
) ;; while
) ;; let - loop
(gimp-quit 0)
)
)
