File indexing completed on 2024-06-16 04:17:40

0001 # SPDX-License-Identifier: CC0-1.0
0002 
0003 """
0004 This script will iterate over all toplevel nodes, create
0005 keeping track of the layer boundaries and then resize
0006 the image to the unity of all boundaries.
0007 """
0008 
0009 from krita import Krita
0010 from PyQt5.QtCore import QRect
0011 
0012 d = Krita.instance().activeDocument()
0013 w = d.width()
0014 h = d.height()
0015 x = d.xOffset()
0016 y = d.yOffset()
0017 
0018 print(x, y, w, h)
0019 r = QRect(x, y, w, h)
0020 print(r)
0021 for n in d.topLevelNodes():
0022     print(n, n.bounds())
0023     b = n.bounds()
0024     r = r.united(b)
0025 
0026 print(r)
0027 
0028 d.resizeImage(r.x(), r.y(), r.width(), r.height())