Q: Batch script adding alpha mask problem
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
Q: Batch script adding alpha mask problem | spiderman | 05 Aug 19:11 |
Q: Batch script adding alpha mask problem | spiderman | 05 Aug 19:12 |
Q: Batch script adding alpha mask problem | spiderman | 05 Aug 19:16 |
Q: Batch script adding alpha mask problem | Michael Schumacher | 05 Aug 19:22 |
Q: Batch script adding alpha mask problem | spiderman | 05 Aug 19:27 |
Q: Batch script adding alpha mask problem | Kevin Cozens | 05 Aug 22:28 |
Q: Batch script adding alpha mask problem | spiderman | 05 Aug 23:03 |
- postings
- 5
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...
- postings
- 5
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...
- postings
- 5
Q: Batch script adding alpha mask problem
(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" ............
Q: Batch script adding alpha mask problem
On 05.08.2013 21:16, spiderman wrote:
[the same(?) script for the third time]
Are there supposed to be any differences between those scripts?
Regards, Michael
- postings
- 5
Q: Batch script adding alpha mask problem
[the same(?) script for the third time]
Are there supposed to be any differences between those scripts?
sorry, it was just to get a good formating for readability.
I forgot to say, that the scipt runs without errors. Images are processed, but no alpha channel is applied.
Regards...
Q: Batch script adding alpha mask problem
On 13-08-05 03:11 PM, spiderman wrote:
I'm new at GIMP scripting. My task is to do a batch processing over an folder with images. I want to add an alpha layer to every image (png). The alpha layer is from a static second image (bmp).
I had to add an alpha mask to 22 images. I just used ImageMagick as it was easy to do that way and saved the need to write a script. I've only looked briefly at your script. Nothing obvious jumps out at me. I'd look at the return values from the function calls. Some operations can change the ID's of layers or drawables and you need to use the new ID's for later operations.
I don't see why you used file globbing to get the alpha mask image. BTW, you can combine car and cadr in to one operation. In Script-Fu scripts you can have up to four letters between c and r for things like car, cadr, up all variations from caaaar to cddddr.
Cheers! Kevin. http://www.ve3syb.ca/ |"Nerds make the shiny things that distract Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're | powerful!" #include | --Chris Hardwick
- postings
- 5
Q: Batch script adding alpha mask problem
Thank you Kevin,
just downloaded Imagemagick for Windows and my task is done with a single command :-)
Found it here:
My efforts with gimp referred to this post:
Greetings...