1.0.0 • Published 6 years ago

2tikz v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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);
    });