Skip to content
forked from dennwc/gotrace

Pure Go implementation of Potrace vectorization library

License

Notifications You must be signed in to change notification settings

go-forks/gotrace

This branch is 1 commit ahead of, 1 commit behind dennwc/gotrace:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

136767a · Jul 1, 2021

History

13 Commits
Dec 10, 2018
Nov 11, 2015
Jan 6, 2021
Dec 10, 2018
Dec 10, 2018
Nov 11, 2015
Dec 10, 2018
Dec 10, 2018
Dec 10, 2018
Nov 11, 2015
Dec 10, 2018
Jul 1, 2021

Repository files navigation

GoTrace

Pure Go implementation of Potrace vectorization library. Supports simple SVG output generation.

Also includes cgo bindings for the original Potrace library.

Original image

Original

Vectorized image

Vectorized

Installation

go get github.com/dennwc/gotrace

Usage

Process image with an alpha channel, generate SVG:

bm := gotrace.NewBitmapFromImage(img, nil)
paths, _ := gotrace.Trace(bm, nil)
gotrace.WriteSvg(file, img.Bounds(), paths, "")

Custom threshold function:

bm := gotrace.NewBitmapFromImage(img, func(x, y int, c color.Color) bool {
    r, g, b, _ := c.RGBA()
    return r + g + b > 128
})
paths, _ := gotrace.Trace(bm, nil)

About

Pure Go implementation of Potrace vectorization library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 58.4%
  • Go 41.6%