svg-attrs

Get svg attributes

Usage no npm install needed!

<script type="module">
  import svgAttrs from 'https://cdn.skypack.dev/svg-attrs';
</script>

README

svg-attrs

Get attributes of a svg.

Installation

npm i -D svg-attrs
# or
yarn add --dev svg-attrs

Usage

Get attributes from a svg file path

const svgAttrs = require('svg-attrs')

svgAttrs.file('./test.svg', (err, attrs) => {
    if (err) {
        console.error(err)
    } else {
        let width = attrs.width
        let height = attrs.height
        
        let attrs = attrs.attrs
    }
})

Get attributes from a svg string

const svgAttrs = require('svg-attrs')

svgAttrs.string('svg string', (err, attrs) => {
    if (err) {
        console.error(err)
    } else {
        let width = attrs.width
        let height = attrs.height
        
        let attrs = attrs.attrs
    }
})

License

MIT