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

2013-08-05 Thread spiderman
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)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread spiderman
>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)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread spiderman

(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" 

-- 
spiderman (via www.gimpusers.com/forums)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread spiderman
>[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...

-- 
spiderman (via www.gimpusers.com/forums)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread spiderman
Thank you Kevin,

just downloaded Imagemagick for Windows and my task is done with a single
command :-)

Found it here:

http://stackoverflow.com/questions/5647840/how-to-combine-rgb-image-and-8-bit-alpha-image-into-single-png-file-with-imagema


My efforts with gimp referred to this post:

http://graphicdesign.stackexchange.com/questions/8397/gimp-using-an-image-as-the-transparency-layer-of-another-image

Greetings...


-- 
spiderman (via www.gimpusers.com/forums)
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread Michael Schumacher
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
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list


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

2013-08-05 Thread Kevin Cozens

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 cr to cr.



--
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
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list