Find empty layers and delete them

This should work. Compared to the script in the linked thread, it checks exactBounds instead of extent.

from krita import *

doc = Krita.instance().activeDocument()
root = doc.rootNode()

allNodes = root.findChildNodes("", True)
for layer in allNodes:
    if layer.bounds().isEmpty():
        layer.remove()
4 Likes