2.6.0 • Published 3 years ago

svg-thumbnailer v2.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

svg-thumbnailer

Overview

Convert almost any image into a vibrant, optimized SVG with NodeJS.

Usage (lib)

const toSvg = require('svg-thumbnailer')

const options = {}

const svgObj = await toSvg('./my/img.jpg', options)
const {data, info: {height, width}} = svgObj

Options (= default)

  • .colors = 4
  • .scale = 1
  • .vibrant = true - via color-thief
    • tries to quantize palette with most "vibrant"/prominent colors.
    • may not look as good with a high amount of .colors.

Optimizations

  • .tolerance = 0.0 (range: 0.0 - 3.0) - via simplify-js
    • when > 0.0, tries to reduce amount of line points (higher = less points).
  • .decimalPlaces = true
    • when false, tries to round many X,Y points to nearest integer.
  • .smooth = 0.0 (range: 0.0 - 0.3)
    • when > 0.0 tries to round out harsh line corners with bezier curves (higher = more rounded).
    • WARNING: significant increase of file size!

Usage (cli)

npm install -g svg-thumbnailer

svg-thumbnailer {image-path} {options?}

Eg. svg-thumbnailer "/path/to/local/images/folder/img.jpg" --colors=4 --vibrant=true

Eg. svg-thumbnailer "/path/to/local/images/folder/" --colors=4 --vibrant=true

Options

  • writeFileWithTag (eg. svg)
    • writes to file, using the image's file name as prefix. Otherwise, writes to console.
  • clobberFile = true
    • when false, if the output file already exists, it is skipped.

Quality

$ npm t

$ npm run lint

Supported Filetypes

  • .png
  • .jpeg|.jpg

Sample

cartoon dog

$ svg-thumbnailer ./resources/cartoon-dog.jpg --writeFileWithTag=svg --colors=6

cartoon dog svg

2.6.0

3 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago