Krita Source Code Documentation
Loading...
Searching...
No Matches
resize_to_all_layers.py
Go to the documentation of this file.
1# SPDX-License-Identifier: CC0-1.0
2
3"""
4This script will iterate over all toplevel nodes, create
5keeping track of the layer boundaries and then resize
6the image to the unity of all boundaries.
7"""
8
9from krita import Krita
10try:
11 from PyQt6.QtCore import QRect
12except:
13 from PyQt5.QtCore import QRect
14
15d = Krita.instance().activeDocument()
16w = d.width()
17h = d.height()
18x = d.xOffset()
19y = d.yOffset()
20
21print(x, y, w, h)
22r = QRect(x, y, w, h)
23print(r)
24for n in d.topLevelNodes():
25 print(n, n.bounds())
26 b = n.bounds()
27 r = r.united(b)
28
29print(r)
30
31d.resizeImage(r.x(), r.y(), r.width(), r.height())
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390