2tikz

1.0.0 • Public • Published

2tikz

2tikz is a small standalone http server that accepts svg and png data and returns tikz code, which can be compiled with latex.
Png files will be vectorized using potrace. Bear in mind that that means, that text content in the pngs will be of varying quality in the resulting .tikz file. Also potrace only supports greyscale output.

requirements

  • NPM
  • Python

setup

npm install

This downloads all needed dependencies and creates a python virtualenv including svg2tikz.

starting the server

npm run

example requests

PNG:

$.ajax({
    "url": url,
    "method": "POST",
    "accepts": {
        "text": "text/plain"
    },
    "data": pngDataUri,
    "content-type": "image/png",
    "processData": false
})
    .then(function (data) {
        console.log(data);
    }, function (error) {
        console.warn(error);
    });

SVG:

$.ajax({
    "url": url,
    "method": "POST",
    "accepts": {
        "text": "text/plain"
    },
    "data": svgString,
    "content-type": "image/svg+xml",
    "processData": false
})
    .then(function (data) {
        console.log(data);
    }, function (error) {
        console.warn(error);
    });

Readme

Keywords

none

Package Sidebar

Install

npm i 2tikz

Weekly Downloads

24

Version

1.0.0

License

ISC

Unpacked Size

11.3 kB

Total Files

5

Last publish

Collaborators

  • yeldir