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.
- Host: GitHub
- URL: https://github.com/tserious/svgtojson
- Owner: TSerious
- Created: 2023-02-07T09:08:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T12:36:03.000Z (over 3 years ago)
- Last Synced: 2025-01-13T18:50:15.155Z (over 1 year ago)
- Language: JavaScript
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
- Initialize npm in the directory:
npm init -y
- Install browserify:
npm install browserify --save
- Install the npm package that you want to use. This tool uses (as said) svgson. Therefore:
npm install svgson --save
- 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
- 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
- Include the created js file in your html. For example:
- Inside a script in html you you can use the exported module. For example:
svgson.parse()