1.0.2 • Published 3 years ago

svg2png-converter v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

svg2png

Lightweight TypeScript SVG to PNG converter.

Usage

If you want to generate a PNG dataURI, you can call Svg2Png.toDataURL(source, options), which returns a Promise. As a source you can use an SVG element or a selector that refers to an element in DOM. If you want to download your SVG as PNG, you can call Svg2Png.save(source, name, options)

Installation

To install with npm:

npm i svg2png-converter

Examples

import {Svg2Png} from 'svg2png-converter';

const svg = document.querySelector('svg');
const options = {
    scaleX: 2,
    scaleY: 2
};

Svg2Png.toDataURL(svg, options).then(url => {
    document.querySelector('img').setAttribute('src', url);
});
import {Svg2Png} from 'svg2png-converter';

Svg2Png.save('svg', 'icon');

Options

Please note that all options are optional.

OptionDefault value
scaleX1
scaleY1
embedCSStrue
1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago