Git Product home page Git Product logo

svg-normalize's Introduction

Resizes and centers any svg to specified viewBox (default is 0 0 32 32)

Usage:

node transform-svg.js "svg-name.svg" --viewBox="0 0 32 32"


node transform-svg.js /home/svgs-to-convert --outFolder=/home/converted --toJsTemplate --viewBox="0 0 32 32"

node transform-svg.js '<svg width="37" height="30" viewBox="0 0 37 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M32.3496 11.5833C32.2566 ... 11.5833Z" fill="#080808"/>
</svg>'

Params:

  • first anonymous argument - either file or directory with svg files to process
  • --file - specific file to convert, takes priority over --directory
  • --directory - specify folder that contains svgs to convert
  • --toJsTemplate - create js template files for human Icon component - default: true
    • this command will also strip colors and all other unneccessary attributes from svg paths
  • --outFolder - specify folder where to output files - default is either folder of the converted file, or sibling directory (+converted) of selected dir
  • --viewBox - specify new viewBox for svg file - default: 0 0 32 32
  • --removeFills - remove all fills in svg - default: true
  • --precision - number of decimal points for output values - default: 3

ToDo:

  • probable glitch when parsing options
  • separate all functions to files
  • find a way to conect "node transform-svg.js" to an alias on "npm i"

svg-normalize's People

Contributors

rtl-machine avatar webbugt avatar

Stargazers

Aleksandr Beliaev avatar

Watchers

 avatar

Forkers

svg-beauty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.