Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++
609 B
Raw Blame
# SPDX-License-Identifier: CC0-1.0

"""
This script will iterate over all toplevel nodes, create
keeping track of the layer boundaries and then resize
the image to the unity of all boundaries.
"""

from krita import Krita
try:
    from PyQt6.QtCore import QRect
except:
    from PyQt5.QtCore import QRect

d = Krita.instance().activeDocument()
w = d.width()
h = d.height()
x = d.xOffset()
y = d.yOffset()

print(x, y, w, h)
r = QRect(x, y, w, h)
print(r)
for n in d.topLevelNodes():
    print(n, n.bounds())
    b = n.bounds()
    r = r.united(b)

print(r)

d.resizeImage(r.x(), r.y(), r.width(), r.height())