Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
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!
});
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
.
@skyzyx made a CLI version of this; you should go check it out if you're into using the command line.
FAQs
Converts SVGs to PNGs, using PhantomJS
The npm package svg2png receives a total of 12,664 weekly downloads. As such, svg2png popularity was classified as popular.
We found that svg2png demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.