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
"""
4
This script will iterate over all toplevel nodes, create
5
keeping track of the layer boundaries and then resize
6
the image to the unity of all boundaries.
7
"""
8
9
from
krita
import
Krita
10
try
:
11
from
PyQt6.QtCore
import
QRect
12
except
:
13
from
PyQt5.QtCore
import
QRect
14
15
d =
Krita.instance
().activeDocument()
16
w = d.width()
17
h = d.height()
18
x = d.xOffset()
19
y = d.yOffset()
20
21
print(x, y, w, h)
22
r = QRect(x, y, w, h)
23
print(r)
24
for
n
in
d.topLevelNodes():
25
print(n, n.bounds())
26
b = n.bounds()
27
r = r.united(b)
28
29
print(r)
30
31
d.resizeImage(r.x(), r.y(), r.width(), r.height())
Krita::instance
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition
Krita.cpp:390
QtCore
QtCore
plugins
python
example_scripts
resize_to_all_layers.py
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52