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

https://github.com/tserious/svgtojson

This is a simple tool written in html an js to convert a svg image to json.
https://github.com/tserious/svgtojson

Last synced: 10 days ago
JSON representation

This is a simple tool written in html an js to convert a svg image to json.

Awesome Lists containing this project

README

          

# svgToJson
This is a simple tool written in html an js to convert a svg image to json.
To achieve this, this tool uses [svgson](https://github.com/elrumordelaluz/svgson#readme).

# Usage
Download everything and start 'convert.htm'.

# Developer notes
To use a npm package in html you have to


  1. Initialize npm in the directory: npm init -y

  2. Install browserify: npm install browserify --save

  3. Install the npm package that you want to use. This tool uses (as said) svgson. Therefore: npm install svgson --save

  4. Create the file 'index.js' and add the exported module (package) to it. So the index.js looks like this:
    const svgson = require('svgson');
    
    module.exports=svgson


  5. Output the module exported to a js file that you can use in the html. To do this run:
    node_modules/.bin/browserify index.js -s [name of module] > [name of output JavaScript file]

    Replace [name of module] with the name of the exported module and replace [name of output JavaScript file] with the name of the js file that will be created, For this tool the command looks like this:
    node_modules/.bin/browserify index.js -s svgson > svgson.js


  6. Include the created js file in your html. For example:

  7. Inside a script in html you you can use the exported module. For example: svgson.parse()