Skip to content

Latest commit

 

History

History
99 lines (67 loc) · 3.01 KB

README.md

File metadata and controls

99 lines (67 loc) · 3.01 KB

Go Legofy

Build Status

Go Report Card

GitHub issues GitHub forks GitHub stars GitHub license

What is it?

Go Legofy is a Go lang utility library that takes a static image and makes it so that it looks as if it was built out of LEGO.

Before

Before

After

After

Quickstart

$ go get github.com/winhtaikaung/go-legofy

Usage

    //Legofy from image path
import (
	"fmt"
	"image"
	_ "image/jpeg"
	"image/png"
	_ "image/png"
	"os"

	"github.com/winhtaikaung/go-legofy/legofy"
)

func main() {
	fmt.Println("Lego My lovely Lego")
	//Legofy from image path
	sourceImagePath := "gopher.png"
	imgChanel := make(chan *legofy.LegoImage)
	go legofy.LegofyImagePath(sourceImagePath, 50, imgChanel)
	img := <-imgChanel
	close(imgChanel)
	fmt.Println(img.BrickCount)
	legofy.SaveAsJPEG("lego_with_path", img.Image, 100)

	// legofy from image.Image data type
	source, _ := os.Open(sourceImagePath)
	defer source.Close()
	sourceImg, _, _ := image.Decode(source) // Image Struct
	imgChanel = make(chan *legofy.LegoImage)
	go legofy.LegofyImage(sourceImg, 50, imgChanel)
	img = <-imgChanel
	close(imgChanel)
	legofy.SaveAsPNG("lego_with_img", img.Image, png.BestCompression)

}

Docs

https://godoc.org/github.com/winhtaikaung/go-legofy/legofy

Bugs

If you find a bug:

  1. Check in the open issues if the bug already exists.
  2. If the bug is not there, create a new issue with clear steps on how to reproduce it.

ToDo

  • Image Palette

Contributing

  1. Fork it ( https://github.com/winhtaikaung/go-legofy )
  1. Create your feature branch (git checkout -b my-new-feature)
  1. Commit your changes (git commit -am 'Add some feature')
  1. Push to the branch (git push origin my-new-feature)
  1. Create a new Pull Request

License

MIT

Twitter