Socket
Socket
Sign inDemoInstall

svg2png

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg2png

A SVG to PNG converter, using PhantomJS


Version published
Weekly downloads
15K
increased by5.27%
Maintainers
1
Weekly downloads
 
Created
Source

SVG-to-PNG Converter Using PhantomJS

You have a SVG file. For whatever reason, you need a PNG. svg2png can help.

svg2png("source.svg", "dest.png", function (err) {
    // PNGs for everyone!
});

Maybe you need to scale the image while converting? We can do that too:

svg2png("source.svg", "dest.png", 1.2, function (err) {
    // 1.2×-sized PNGs for everyone!
});

The scale factor is relative to the SVG's viewbox or width/height attributes, for the record.

Maybe you need an image with exact dimensions:

svg2png("source.svg", "dest.png", { width: 200, height: 150 }, function (err) {
    // 200x150 pixel sized PNGs for everyone!
});

The image will be centered and zoomed to best-fit but not stretched. You can also provide just a single dimension and the other one will be inferred automatically:

svg2png("source.svg", "dest.png", { width: 300 }, function (err) {
    // 300 pixel-wide PNGs for everyone!
});

How the conversion is done

svg2png is built on the latest in PhantomJS technology to render your SVGs using a headless WebKit instance. I have found this to produce much more accurate renderings than other solutions like GraphicsMagick or Inkscape. Plus, it's easy to install cross-platform due to the excellent phantomjs npm package—you don't even need to have PhantomJS in your PATH.

CLI

@skyzyx made a CLI version of this; you should go check it out if you're into using the command line.

FAQs

Package last updated on 09 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc