# oslllo-svg2

> Convert a SVG to multiple image formats (without puppeteer or a headless browser)

Latest version **5.0.0** (published 2025-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install oslllo-svg2
pnpm add oslllo-svg2
yarn add oslllo-svg2
bun add oslllo-svg2
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-12-22 |
| First published | 2020-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Ghustavh Ehm |
| Maintainers | ghustavh97 |
| Keywords | svg2, oslllo, convert, svg-png, svg-bmp, svg-jpeg, svg-tiff, svg-image, svg-image, svg-to-png, svg-to-bmp, svg-to-jpeg, svg-to-tiff, svg-to-image, svg-to-element |

## Links

- npm: https://www.npmjs.com/package/oslllo-svg2
- Repository: https://github.com/oslllo/svg2
- Homepage: https://docs.oslllo.com/svg2/master
- Issues: https://github.com/oslllo/svg2/issues
- npm.io page: https://npm.io/package/oslllo-svg2

## Dependencies (4)

- [jimp](https://npm.io/package/jimp.md) ^0.22.12
- [domino](https://npm.io/package/domino.md) ^2.1.6
- [@resvg/resvg-js](https://npm.io/package/@resvg/resvg-js.md) ^2.6.2
- [oslllo-validator](https://npm.io/package/oslllo-validator.md) ^4.0.0

## 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

- 5.0.0 (latest) — 2025-12-22
- 4.0.0 — 2024-11-21
- 3.0.0 — 2024-07-21
- 2.0.2 — 2022-07-16
- 2.0.1 — 2022-05-01
- 2.0.0 — 2022-01-21
- 1.0.0 — 2022-01-12
- 0.3.1 — 2021-09-05
- 0.3.0 — 2021-07-14
- 0.2.4 — 2021-05-06
- 0.2.3 — 2021-04-01
- 0.2.2 — 2020-12-12
- 0.2.1 — 2020-10-01
- 0.2.0 — 2020-09-17
- 0.1.0 — 2020-08-31
- … 2 more at https://npm.io/package/oslllo-svg2/versions

## README

![Cover Image](docs/images/cover.png)

[![CI/Test](https://github.com/oslllo/svg2/actions/workflows/ci.test.yml/badge.svg)](https://github.com/oslllo/svg2/actions/workflows/ci.test.yml)
[![npm](https://img.shields.io/npm/v/oslllo-svg2)](https://www.npmjs.com/package/oslllo-svg2)
[![Coverage Status](https://img.shields.io/coveralls/github/oslllo/svg2)](https://coveralls.io/github/oslllo/svg2?branch=master)

## 🎉 v1.0.0 Removed `Canvas & JSDOM` no more slow `npm install` cycles.

## Documentation, Installation, and Usage Instructions

See the full installation and usage documentation [HERE](https://docs.oslllo.com/svg2/master/).

## The Objective

I wanted to convert `SVGs` into diffrent image formats.

## The Problem / Why

Converting a `SVG` into an image turns out to not be a simple and straight forward as it may seem. Multiple packages already exist on `NPM` but they all come with a few caveats (that i don't like).

- Some use `puppeteer` which requires you to download a browser like chromium **(130mb download)**
- Some do not support `Node` **(work in browsers only)**
- Some support `CLI` only.
- Some only convert to `png`

---

### Usage Examples

#### Convert a SVG2 `png` and save to path (promise)

```js
const Svg2 = require("oslllo-svg2");

Svg2("path/to/svg/example.svg")
  .png()
  .toFile("path/to/save/example.png")
  .then(() => {
    console.log("done");
  })
  .catch((error) => {
    throw error;
  });
```

#### Convert a SVG2 `png` and save to path (callback)

```js
const Svg2 = require("oslllo-svg2");

Svg2("path/to/svg/example.svg")
  .png()
  .toFile("path/to/save/example.png", (err) => {
    if (err) {
      throw err;
    } else {
      console.log("done");
    }
  });
```

---

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