GIMP Python-fu exporting file only exports transparent layer

浪尽此生 提交于 2019-12-04 11:21:45

I found my problem! I was not merging the visible layers and setting that equal to the new layer, which I then used as the "drawable object" when saving the image as a png! I have posted the fixed code below:

image_array = gimp.image_list()
i=0
for image in image_array:
    img = image_array[i]
    layers = img.layers
    last_layer = len(layers)-1
    try:
        disable=pdb.gimp_image_undo_disable(img)
        pdb.gimp_layer_add_alpha(layers[0])
        drw = pdb.gimp_image_active_drawable(img)
        pdb.plug_in_colortoalpha(img,drw,(0,0,0))
        layer = pdb.gimp_image_merge_visible_layers(img, gimpfu.CLIP_TO_IMAGE)#FIXES PROBLEM OF ONLY EXPORTING TRANSPARENCY!
        enable = pdb.gimp_image_undo_enable(img)

    except:
        print "ERROR"

    pdb.file_png_save2(img, layer, "C:\\Users\\jammer\\Desktop\\test.png","test.png",1,9,1,1,1,1,1,0,1)
    i+=1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!