Using Script -Fu loading and saving PNG loses alpha

I am trying to write a script in GIMP that will load a PNG file and save it again with maximum compression (I also plan to add other processing steps). However, the following script seems to destroy alpha information:

(define (process-png pattern) (let* ( (filelist (cadr (file-glob pattern 1))) ) (while (not (null? filelist)) (begin (catch () (let* ( (filename (car filelist)) (image (car (file-png-load RUN-NONINTERACTIVE filename filename))) ) (begin (file-png-save2 RUN-NONINTERACTIVE image (car (gimp-image-get-active-drawable image)) filename filename 0 9 0 0 0 0 0 0 0) (gimp-image-delete image) ) ) ) (set! filelist (cdr filelist)) ) ) ) ) 

For example, the translucent pixels in jQuery icons seem completely transparent, making everything an alias.

How can this be fixed?

+4
source share
1 answer

The file-png-save2 says the last parameter for Preserve color of transparent pixels? , which in your case is set to 0. Try setting this value to 1, and it should work fine.

+2
source

All Articles