An open API service indexing awesome lists of open source software.

https://github.com/iwstkhr/svg-to-png

A library to convert svg to png (base64)
https://github.com/iwstkhr/svg-to-png

png svg

Last synced: 5 months ago
JSON representation

A library to convert svg to png (base64)

Awesome Lists containing this project

README

        

# svg-to-png
A library to convert svg to png (base64)

## Install
```
npm install https://github.com/iwstkhr/svg-to-png.git
```

## Usage
### HTML
Copy `main.js` to your app js directory.
```
cp node_modules/@iwstkhr/svg-to-png/dist/main.js $YOUR_APP_JS_PATH
```

```html


Title

SVG













PNG (Base64)


Base64

svgToPngLib.svgToPng(document.querySelector('#svg')).subscribe(function (value) {
document.querySelector('#png').setAttribute('src', value);
document.querySelector('#base64').innerHTML = value;
});

```

### TypeScript
```typescript
import { svgToPng } from '@iwstkhr/svg-to-png';

const svg = document.querySelector('#svg') as SVGSVGElement;
svgToPng(svg).subscribe(value => console.info(value));
```

## License
MIT