# @bpmn-io/svg-to-image

> Utility for generating images from SVG markup

Latest version **1.0.1** (published 2026-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bpmn-io/svg-to-image
pnpm add @bpmn-io/svg-to-image
yarn add @bpmn-io/svg-to-image
bun add @bpmn-io/svg-to-image
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2026-02-17 |
| First published | 2026-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bpmn.io contributors |
| Maintainers | bpmn-io-admin, nikku, barmac, philippfromme, maxtru, skaiir-camunda, vsgoulart, barinali, jarekdanielak, alekseymanetov, simon-steinruecken-camunda |
| Keywords | svg, image, png, jpeg |

## Links

- npm: https://www.npmjs.com/package/@bpmn-io/svg-to-image
- Repository: https://github.com/bpmn-io/svg-to-image
- Homepage: https://github.com/bpmn-io/svg-to-image#readme
- Issues: https://github.com/bpmn-io/svg-to-image/issues
- npm.io page: https://npm.io/package/@bpmn-io/svg-to-image

## Dependencies (1)

- [canvg](https://npm.io/package/canvg.md) ^4.0.3

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2026-02-17
- 1.0.0 — 2026-02-17

## README

# @bpmn-io/svg-to-image

[![CI](https://github.com/bpmn-io/svg-to-image/actions/workflows/CI.yml/badge.svg)](https://github.com/bpmn-io/svg-to-image/actions/workflows/CI.yml)

Converts an SVG to an image with decent quality.

## Usage

```javascript
import { svgToImage } from 'svg-to-image';

const svg = '<svg>...</svg>';

// Generate PNG
const result = await svgToImage(svg, {
    imageType: 'png',
    outputFormat: 'blob'
});
```

## Build and Run

```
# install dependencies
npm install

# run project, executing all tasks
npm run all
```

## How it works

This package uses [canvg](https://github.com/canvg/canvg) to render SVG elements onto a canvas and then exports them as image data URLs or [image blobs](https://developer.mozilla.org/en-US/docs/Web/API/Blob).

## License

MIT

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