Skip to content

Commit ace4438

Browse files
committed
Add Tree::max_size to compute actual SVG size
1 parent ded4b13 commit ace4438

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/usvg/src/tree/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,15 @@ impl Tree {
15731573
self.size
15741574
}
15751575

1576+
/// Returns the actual size of the image, accounting for strokes, filters
1577+
/// and transforms.
1578+
///
1579+
/// May exceed the original [`size`](Tree::size).
1580+
pub fn max_size(&self) -> Size {
1581+
let bbox = self.root().abs_layer_bounding_box();
1582+
Size::from_wh(bbox.width(), bbox.height()).unwrap_or(self.size)
1583+
}
1584+
15761585
/// The root element of the SVG tree.
15771586
pub fn root(&self) -> &Group {
15781587
&self.root

0 commit comments

Comments
 (0)