An open API service indexing awesome lists of open source software.

https://github.com/retorillo/pixelated-svg

Create SVG vector image from raster image with keeping pixelated visual.
https://github.com/retorillo/pixelated-svg

converter nodejs pixel-art png svg

Last synced: 22 days ago
JSON representation

Create SVG vector image from raster image with keeping pixelated visual.

Awesome Lists containing this project

README

        

# pixelated-svg

[![Build Status](https://travis-ci.org/retorillo/pixelated-svg.svg?branch=master)](https://travis-ci.org/retorillo/pixelated-svg)
[![Coverage Status](https://coveralls.io/repos/github/retorillo/pixelated-svg/badge.svg?branch=master)](https://coveralls.io/github/retorillo/pixelated-svg?branch=master)
[![Dependency Status](https://gemnasium.com/badges/github.com/retorillo/pixelated-svg.svg)](https://gemnasium.com/github.com/retorillo/pixelated-svg)
[![NPM](https://img.shields.io/npm/v/pixelated-svg.svg)](https://www.npmjs.com/package/pixelated-svg)
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Create SVG vector image from raster image with keeping pixeleated visual.

## Functions

### fromPng

Create SVG document from PNG file. Asynchronous function. Returns `Promise`.
See also [Options](#options).

```javascript
const svg = require('pixelated-svg');
svg.fromPng('foobar.png').then(svg => {
console.log(svg);
// =`, `>`)

For example,

```javascript
const selector = ['< 249', '>= 35', 156, '*'];
svg.fromPng('rgb.png', {
includeColors: [ selector ],
}).then(...);
```

This can select colors that satisfy the next conditions:

- R < 249
- B >= 35
- G == 156
- A can be any value

## CLI

Command line interface will be available when globally installed. (`npm install -g pixelated-svg`)

```bash
pixelated-svg raster.png --scale 100 > out.svg
```

Command line options correspond with `fromPng` options:

- `--scale` or `-s`
- Corresponds with `scale`.
- `--include`, `-i`, `--exclude`, `-e` (Experimental)
- Correspond with `includeColors` and `excludeColors` options
- Syntax must be "exact" JSON Array format. (eg. `-i "[[171, 70, 66, 255]]"`).
- This inconvenient constraint will be change later.

## License

MIT License

(C) 2017 Retorillo