## How to export every layer as single image ```python import os import gimpfu def export_layers(image, drawable): image_uri = gimpfu.pdb.gimp_image_get_uri(image) image_path = image_uri[7:] # Removing 'file://' from the URI output_folder = os.path.dirname(image_path) if output_folder and os.path.exists(output_folder): for i, layer in enumerate(image.layers, start=1): filename = "layer_{:03}.png".format(i) filepath = os.path.join(output_folder, filename) tmp_image = gimpfu.pdb.gimp_image_new(image.width, image.height, image.base_type) layer_copy = gimpfu.pdb.gimp_layer_new_from_drawable(layer, tmp_image) gimpfu.pdb.gimp_image_insert_layer(tmp_image, layer_copy, None, 0) gimpfu.pdb.file_png_save_defaults(tmp_image, layer_copy, filepath, filename) gimpfu.pdb.gimp_image_delete(tmp_image) else: gimpfu.gimp_message("Please save the image first to determine the output directory.") def register_export_layers(): gimpfu.register( "python_fu_export_layers", "Export all layers", "Exports all layers as separate PNG files", "Your Name", "Your Name", "2024", "Export Layers...", "*", # This makes the script available for all types of images [ (gimpfu.PF_IMAGE, "image", "Input image", None), (gimpfu.PF_DRAWABLE, "drawable", "Input drawable", None), ], [], export_layers, menu="/File/Export/" ) gimpfu.main() register_export_layers() ```