How do I save (export) all layers with gimp's script fu?

前端 未结 3 1194
旧时难觅i
旧时难觅i 2021-02-07 21:11

With gimp fu, I can save the content of one layer (at least, that is how I interprete the definition of gimp_file_save because it takes the parameter

3条回答
  •  灰色年华
    2021-02-07 22:01

    What is done internally, even by GIMP file-exporter plug-ins for all formats is: duplicate the image, merge all visible layers, them save the resulting drawable.

    This is easier, and take less resources than it sounds. Effectively you just have to replace your save line

    pdb.gimp_file_save(img, background_layer, '/temp/tq84_write_text.png', '?')
    

    by

    new_image = pdb.gimp_image_duplicate(img)
    layer = pdb.gimp_image_merge_visible_layers(new_image, CLIP_TO_IMAGE)
    pdb.gimp_file_save(new_img, layer, '/temp/tq84_write_text.png', '?')
    pdb.gimp_image_delete(new_image)
    

    (The last call just "deletes" the new image from program memory, freeing up the resources, of course)

提交回复
热议问题