mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
558 stars 142 forks source link

Extract bounding box from SVG path #150

Open FraPochetti opened 3 years ago

FraPochetti commented 3 years ago

Hi, I want to extract the bounding box from the object stored in an SVG path. Can you please confirm that what I am doing is the official way of achieving this?

from svgpathtools import Path
from svgpathtools.paths2svg import big_bounding_box
svg_path = Path('SVG path')
xmin, xmax, ymin, ymax = big_bounding_box([svg_path])  

Thanks!

Vrroom commented 3 years ago

Have you tried:

svg_path = Path('SVG path')
xmin, xmax, ymin, ymax = svg_path.bbox()

That's what I used when I needed a path's bounding box.