[Gimp-user] Q: Batch script adding alpha mask problem



Hi,

I'm new at GIMP scripting. My task is to do a batch processing over an folder
with images. Iwant to add an alpha layer to every image (png).
The alpha layer is from a static second image (bmp).

I can accomplish the task in the GIMP frontend manually, but the exactly same
steps in my script aren't working.
What am I doing wrong?

Here's the script:

(define (script-fu-batch-alpha-add globalpha globpics)
  (let* ((filelist (cadr (file-glob globpics 1)))
                 (filealpha (car(cadr (file-glob globalpha 1))))
                 (imgalpha (car (gimp-file-load RUN-NONINTERACTIVE
                                              filealpha filealpha)))
         (drawablealpha (car (gimp-image-get-active-layer imgalpha)))
                                                                                          
                                                                                          )
                (gimp-selection-all imgalpha)      ;copy my static alpha image 
                (gimp-edit-copy drawablealpha)  ; to buffer and reuse it with every image 
                
    (while (not (null? filelist))
           (let* ((filename (car filelist))
                  (image (car (gimp-file-load RUN-NONINTERACTIVE
                                              filename filename)))
                  (drawable (car (gimp-image-get-active-layer image)))
                                  (mask (car (gimp-layer-create-mask drawable 2)))
                                  ) ; add an alpha channel layer mask
                                  (gimp-image-undo-disable image)
                                  (gimp-layer-add-mask drawable mask)
                                  (gimp-layer-set-edit-mask drawable 1)
                                  (gimp-layer-set-show-mask drawable 0)
                                  (gimp-layer-set-apply-mask drawable 1)
(gimp-edit-paste drawable 1)            ; paste static alpha image to layer mask
(WHICH IS NOT WORKING in BATCH )
                                  (file-png-save-defaults RUN-NONINTERACTIVE
                             image drawable filename filename)
             (gimp-image-delete image))
           (set! filelist (cdr filelist))))
)

; register
(script-fu-register "script-fu-batch-alpha-add" ............

Thanks for your help...

-- 
spiderman (via www.gimpusers.com/forums)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]