Skip to content
Snippets Groups Projects
Louis Capitanchik's avatar
6cf8f93e

PNG to SVG

It converts png images to SVG vectors.

That'is it.

Installation

From Source

  1. Clone this repository
  2. Run "cargo build --release"
  3. Copy target/release/png_to_svg to somewhere in your system's $PATH

Prebuilt (Linux)

  1. Use your favourite method (curl, wget, browser, etc) to download the latest binary: https://lab.lcr.gr/microhacks/png-to-svg/-/jobs/artifacts/trunk/raw/png_to_svg?job=build:application
  2. Copy png_to_svg to somewhere in your system's $PATH

Usage

$: png_to_svg --help
Convert RGBA8 PNG images into SVGs, where each pixel of input creates one output rect

Usage: png_to_svg [OPTIONS] <INPUT_FILE> <OUTPUT_FILE>

Arguments:
  <INPUT_FILE>   
  <OUTPUT_FILE>  

Options:
  -s, --scale <SCALE>  Set the size of each output pixel; creates an NxN rect for each input pixel where N is the scale [default: 1]
  -h, --help           Print help information
  -V, --version        Print version information

Notes

  • The input and output files do not need to have png and svg suffixes, respectively. Instead, the file types are assumed
  • -s and --scale will set affect the width, height, and viewbox attributes of the root <svg> element, and the x, y, width, and height attributes of the pixel rect elements
  • The file size of the SVG equivalent is quite large compared to the original PNG