commit a88ac7f84adf14725dcc32335c8027b8bb67ddda Author: CJSatnarine Date: Sat Feb 28 01:40:38 2026 -0500 initial commit diff --git a/export_layer_as_numbered_files.py b/export_layer_as_numbered_files.py new file mode 100644 index 0000000..a57d143 --- /dev/null +++ b/export_layer_as_numbered_files.py @@ -0,0 +1,34 @@ +from krita import * +import os + +active_document = Krita.instance().activeDocument() +working_directory = os.path.dirname(active_document.fileName()) + +# change the "exported_layers" to whatever folder name you want +export_directory = os.path.join(working_directory, "exported_layers") + +if not os.path.isdir(export_directory): + os.makedirs(export_directory) + +Krita.instance().setBatchmode(True) + +for index, node in enumerate(active_document.topLevelNodes()): + if node.name().lower() in ["background", "references"]: + continue + + InfoObject().setProperty("alpha", True) + InfoObject().setProperty("compression", 9) + InfoObject().setProperty("forceSRGB", False) + InfoObject().setProperty("indexed", False) + InfoObject().setProperty("interlaced", False) + InfoObject().setProperty("saveSRGBProfile", False) + InfoObject().setProperty("transparencyFillcolor", [0,0,0]) + + base_name = os.path.splitext(os.path.basename(active_document.fileName()))[0] + file_name = f"{base_name}_{index:04}_{node.name()}.png" + path = os.path.join(export_directory, file_name) + node.save(path, active_document.resolution(), active_document.resolution(), InfoObject()) + print("Exported: ", file_name, "\n") + +Krita.instance().setBatchmode(False) +print("Export Complete.")