
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
svgexport-forked
Advanced tools
Node.js module and command-line tool for exporting SVG to PNG and JPEG.
svgexport is a Node.js module and command-line tool for exporting SVG files to PNG and JPEG, it uses Puppeteer for rendering SVG files.
npm install svgexport -g
svgexport <input file> <output file> <options>
svgexport <datafile>
<options> [<format>] [<quality>] [<input viewbox>] [<output size>] [<resize mode>] [<styles>]
<format> png|jpeg|jpg
If not specified, it will be inferred from output file extension or defaults to "png".
<quality> 1%-100%
<input viewbox> <left>:<top>:<width>:<height>|<width>:<height>
If input viewbox is not specified it will be inferred from input file.
<output size> <scale>x|<width>:<height>|<width>:|:<height>
If output size is specified as width:height, <viewbox mode> is used.
<viewbox mode> crop|pad
Crop (slice) or pad (extend) input to match output aspect ratio, default mode is "crop".
<datafile> Path of a JSON file with following content:
[ {
"input" : ["<input file>", "<option>", "<option>", ...],
"output": [ ["<output file>", "<option>", "<option>", ...] ]
}, ...]
Input file options are merged with and overridden by output file options.
Instead of a JSON file, a Node module which exports same content can be provided.
Scale 1.5x proportionally:
svgexport input.svg output.png 1.5x
Scale proportionally to set output width to 32px:
svgexport input.svg output.png 32:
Scale proportionally and pad output to set output width:height to 32px:54px:
svgexport input.svg output.png pad 32:54
Export -1:-1:24:24 (left:top:width:height) of input.svg to output.png:
svgexport input.svg output.png -1:-1:24:24 1x
Set output JPEG quality:
svgexport input.svg output.jpg 80%
Use a CSS to style input SVG:
svgexport input.svg output.jpg "svg{background:silver;}"
By default, Puppeteer has a page load timeout of 30 seconds. This might not be
enough for large SVG files. If you want to change the page timeout, set the
SVGEXPORT_TIMEOUT environment variable to the desired number of seconds.
// One minute timeout
SVGEXPORT_TIMEOUT=60 svgexport input.svg output.png
npm install svgexport --save
var svgexport = require('svgexport');
svgexport.render(datafile, callback);
datafile can be an object, an array of objects or a JSON file path, see command line usage for its format.
svgexport was migrated from PhantomJS to Puppeteer by Michael Heerklotz.
Copyright (c) 2016 Ali Shakiba
Available under the MIT license
Keywords: svg, export, rasterize, converter, png, jpeg, jpg, cli, command-line, inkscape, illustrator, coreldraw
FAQs
Node.js module and command-line tool for exporting SVG to PNG and JPEG.
We found that svgexport-forked 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.