/scale-that-svg

Scale that SVG!

Primary LanguageJavaScript

Scale that SVG!

Scale that svg, period.

Install

yarn add scale-that-svg

Usage

const { scale } = require('scale-that-svg')

fs.readFile('./test.svg', (err, input) => {
  scale(input, { scale: 0.5 }).then((scaled) => {
    console.log({ scaled })
  })
})

scale(`<svg viewBox="0 0 500 200">
  <rect
    x="200"
    y="50"
    fill="#F16362"
    stroke="#30456B"
    stroke-width="5"
    stroke-linecap="round"
    stroke-linejoin="round"
    width="100" height="100"/>
</svg>`).then((scaledFromString) => console.log({ scaledFromString }))

API

scale(input,[options])

input

Type: string|buffer SVG to scale

options

Type: Object Based on svg-path-tool scale

scale

Type: number
Default: 1 (no scale)

scaleY

Type: number
If no specified, same as scale

round

Type: number
Default: 3

Related

element-to-path Convert SVG element into path

path-that-svg Convert entire SVG with path

svg-path-tools Tools to manipulate SVG path (d)

svgson Transform SVG into Object

License

MIT © Lionel Tzatzkin