<commit_before># SharpVG

Sharp Vector Graphics

A library and command line utility to convert bitmaps to SVGs.

Why?

- SVG is currently the only reliable way to scale up pixelated graphics with preserving sharpness of the pixels that works across browsers.
- Converting to SVG might be useful in other scenarios, for example when we want to manipulate the image in real time.

Examples (from http://brainshave.com)

<img src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2216%22%20height%3D%2215%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%3E%3Cpath%20d%3D%22M3%2C1h1v1h1v1h6v-1h1v-1h1v3h1v1h1v7h-1v1h-1v1h-10v-1h-1v-1h-1v-7h1v-1h1v-2zM4%2C6v1h-1v5h1v1h2v-1h4v1h2v-1h1v-5h-1v-1h-3v1h-2v-1h-2zM4%2C8h1v3h-1v-2zM11%2C8h1v3h-1v-2zM7%2C10h2v1h-2z%22%20fill%3D%22black%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E">

Features!

- converts bitmaps to SVGs
- currently supports only one-colour GIFs as input (originally created for my own use)
- fancy edge-tracing algorithm to maximally optimise output size

Usage (CLI):

    sharpvg file.gif > file.svg

Usage (node, simple):

    var sharpvg = require("sharpvg")
    var svg = sharpvg(fs.readFileSync("file.gif"))

Usage (node, step by step):

    var sharpvg = require("sharpvg")
    // raw file buffer:
    var data = fs.readFileSync("file.gif")
    // 2-dim array of 1s and 0s:
    var bitmap = sharpvg.gif(data)
    // producing svg is a separate step so we can take the bitmap from
    // different source
    var svg = sharpvg.svg(bitmap)

SharpVG also an experiment in me writing functional code so it uses<commit_msg>Apparently SVGs in READMEs are no-nos.<commit_after># SharpVG

Sharp Vector Graphics

A library and command line utility to convert bitmaps to SVGs.

Why?

- SVG is currently the only reliable way to scale up pixelated graphics with preserving sharpness of the pixels that works across browsers.
- Converting to SVG might be useful in other scenarios, for example when we want to manipulate the image in real time.

Features!

- converts bitmaps to SVGs
- currently supports only one-colour GIFs as input (originally created for my own use)
- fancy edge-tracing algorithm to maximally optimise output size

Usage (CLI):

    sharpvg file.gif > file.svg

Usage (node, simple):

    var sharpvg = require("sharpvg")
    var svg = sharpvg(fs.readFileSync("file.gif"))

Usage (node, step by step):

    var sharpvg = require("sharpvg")
    // raw file buffer:
    var data = fs.readFileSync("file.gif")
    // 2-dim array of 1s and 0s:
    var bitmap = sharpvg.gif(data)
    // producing svg is a separate step so we can take the bitmap from
    // different source
    var svg = sharpvg.svg(bitmap)

SharpVG also an experiment in me writing functional code so it uses
{'fraction_non_alphanumeric': 0.09044862518089725, 'fraction_numerical': 0.05499276410998553, 'mean_word_length': 3.990974729241877, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3534688', 'n_tokens_mistral': 1075, 'n_tokens_neox': 986, 'n_words': 315}