@icon-magic/svg-to-png
TypeScript icon, indicating that this package has built-in type declarations

2.6.0-beta.0 • Public • Published

@icon-magic/svg-to-png

Quickly converts an SVG file to a PNG file using Puppeteer. On process start, it spins up os.cpus() - 1 independent browser instances to farm conversion tasks out across multiple processes. Exports two main methods:

async convertFile(fileName: string, options: SVGToPNGOptions): Promise

Given a path to a file, return the PNG buffer of the converted image.

async convert(contents: string, options: SVGToPNGOptions): Promise

Given the contents of a SVG file, return the PNG buffer of the converted image.

Options

Conversion options use the following interface:

interface SVGToPNGOptions {
  width: number; // Width of the output PNG.
  height: number; // Height of the output PNG.
  headless?: boolean; // If the browser converting the image should be headless or not. Useful for debugging.
}

Readme

Keywords

none

Package Sidebar

Install

npm i @icon-magic/svg-to-png

Weekly Downloads

1

Version

2.6.0-beta.0

License

BSD-2-Clause

Unpacked Size

185 kB

Total Files

24

Last publish

Collaborators

  • thegilby
  • camario25
  • epicmiller
  • rchitloor
  • omayeli