initial commit
This commit is contained in:
34
export_layer_as_numbered_files.py
Normal file
34
export_layer_as_numbered_files.py
Normal file
@@ -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.")
|
||||||
Reference in New Issue
Block a user