# svg-path-bounds

> Get bounding box of an svg path data

Latest version **1.0.2** (published 2021-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install svg-path-bounds
pnpm add svg-path-bounds
yarn add svg-path-bounds
bun add svg-path-bounds
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-05-03 |
| First published | 2017-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/svg-path-bounds) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 70 |
| Author | Dima Yv |
| Maintainers | dfcreative, dy |
| Keywords | svg, boundaries, normalize, coordinate, range, clip, mask, svg path, path |

## Links

- npm: https://www.npmjs.com/package/svg-path-bounds
- Repository: https://github.com/dfcreative/svg-path-bounds
- Homepage: https://github.com/dfcreative/svg-path-bounds#readme
- Issues: https://github.com/dfcreative/svg-path-bounds/issues
- npm.io page: https://npm.io/package/svg-path-bounds

## Dependencies (4)

- [is-svg-path](https://npm.io/package/is-svg-path.md) ^1.0.1
- [abs-svg-path](https://npm.io/package/abs-svg-path.md) ^0.1.1
- [parse-svg-path](https://npm.io/package/parse-svg-path.md) ^0.1.2
- [normalize-svg-path](https://npm.io/package/normalize-svg-path.md) ^1.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-05-03
- 1.0.1 — 2017-08-24
- 1.0.0 — 2017-07-22

## README

# svg-path-bounds [![Build Status](https://travis-ci.org/dfcreative/svg-path-bounds.svg?branch=master)](https://travis-ci.org/dy/svg-path-bounds)

Retrieve bounding box from svg path data.

## Usage

[![npm install svg-path-bounds](https://nodei.co/npm/svg-path-bounds.png?mini=true)](https://npmjs.org/package/svg-path-bounds/)

```js
const getBounds = require('svg-path-bounds')

let [left, top, right, bottom] = getBounds('M0 0L10 10 20 0Z') // [0, 0, 20, 10]
```

## API

### bounds = getBounds(path|segments)

Calculate bounding box for [svg path data](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d) string or [parsed path segments](https://www.npmjs.com/package/parse-svg-path) array. The box is detected by controlling points, not the real path.

## Related

* [parse-svg-path](https://npmjs.org/parse-svg-path) - return svg path data segments
* [abs-svg-path](https://npmjs.org/abs-svg-path) - convert svg path to absolute values
* [rel-svg-path](https://npmjs.org/abs-svg-path) - convert svg path to relative values
* [normalize-svg-path](https://npmjs.org/normalize-svg-path) - make path consist of only bezier curve segments
* [draw-svg-path](https://npmjs.org/draw-svg-path) - create canvas shape based on svg path data
* [normalize-svg-coords](https://npmjs.org/normalize-svg-coords) - bring svg path coordinates to any linear range

## Similar

* [svg-boundings](https://www.npmjs.com/package/svg-boundings)
* [svg-path-bounding-box](https://github.com/icons8/svg-path-bounding-box)

## License

MIT © Dima Yv

---
_Source: https://npm.io/package/svg-path-bounds · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
