npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg-mask2png

v0.4.4

Published

Masked SVG Id to PNG exporter.

Downloads

2

Readme

SVG-mask2PNG

It's a node package to extract to PNG every object inside a SVG file when their ID match a mask.

Important This is not a real extractor! Is more like a helper. You MUST have inkscape in your path to execute the real extraction of images.

Install

npm install [-g] svg-mask2png

Usage

You can require it on your code:

var svgMask2png = require('svg-mask2png');

svgMask2png(['input.svg'], {  // <- notice filename is an array!
    color   : '#f2f2f2',
    outpath : 'images',
    flat    : true
})
.then(function(result){
    console.log('extracted objects: ', result[0]);
    console.log('total objects: ', result[1]);
})
.catch(function(err){
    console.log(err);
});

Or, if installed as global, you can execute:

$ svg-m2png --help

#example
$ svg-m2png -o images input.svg [other.svg ...]

Options

option | default | description ---------- | :-------: | ---------------------- mask | xx | mask to match the start of ID name color | | color to be converted to transparent, must be in form: #123abc outpath | ./ | path to PNG destination n | 3 | number of concurrent processes verbose | false | if you want to print out the name of files while being extracted flat | false | If you don't want to put images of each SVG file inside a subfolder named as the SVG file

Workflow

I like to create all my image assets inside a single SVG file, then name all of them to its final png's name (plus the stating mask).

When creating fixed size images with transparent background I usually use a known color since it is easier to manipulate and define its size. Then group that background with the draw over it, name the group and instruct this helper to convert that color to transparent prior extraction.

$ svg-m2png -o images input.svg --transparent "#f2f2f2"

Developing

If you want to change the code:

# clone it to a local folder
git clone [email protected]:xgvargas/svg-mask2png.git

# install dependencies
npm install -g coffeescript
npm install

# install in dev mode
npm link

# compile code with:
npm run compile
# or
npm run watch