Giter VIP home page Giter VIP logo

gotrace's Introduction

GoTrace

Pure Go implementation of Potrace vectorization library. Supports SVG, PDF and DXF output generation.

It is a direct machine translation (transpilation) of potrace using cxgo.

Original image

Original

Vectorized image

Vectorized

Installation

Tool

go install github.com/gotranspile/gotrace@latest

Usage

Convert PNG image to SVG:

gotrace -s -o ./testdata/stanford.svg ./testdata/stanford.png

Library

go get -u github.com/gotranspile/gotrace

Usage

Minimal example:

func traceImage(outPath string, img image.Image) error {
    bm := gotrace.BitmapFromImage(img, nil)
    
    paths, err := gotrace.Trace(bm, nil)
    if err != nil {
        return err
    }
    
    sz := img.Bounds().Size()
    return gotrace.RenderFile("svg", nil, outPath, paths, sz.X, sz.Y)
}

For a full example, see example_test.go.

Updating the source

This library uses cxgo to translate C source code directly to Go. See cxgo.yml for the config.

To regenerate source, install cxgo and goimports and run:

go generate

gotrace's People

Contributors

dennwc avatar

Stargazers

Jarento avatar Chris Hart avatar Craig Campbell avatar Dobrosław Żybort avatar Dmitry avatar Justin Golden avatar ekis avatar viney avatar  avatar  avatar  avatar Jon Williams avatar MEARAJ BHAGAD avatar

Watchers

 avatar

Forkers

zhuewizz

gotrace's Issues

thankyou

Hey @dennwc

just wanted to say thank you for this package. its works very well for me.

Issue installing

The readme says go install github.com/gotranspile/gotrace@latest to install.

I've installed go and created a new folder, got a hello world go script running, but when I try to install with that command, I get that "gotrace is not a main package"

image

go install github.com/gotranspile/gotrace@latest
go: downloading github.com/gotranspile/gotrace v0.0.0-20230726133510-8c9665a39b09
go: downloading github.com/gotranspile/cxgo v0.3.7
package github.com/gotranspile/gotrace is not a main package

Sorry for the newbie question and thanks in advance 😄

EDIT: I also tried go get github.com/gotranspile/gotrace but got go: go.mod file not found in current directory or any parent directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.