Skip to content

winhtaikaung/go-legofy

Repository files navigation

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

About

Golang legofy which legolize images look as if they are made out of 1x1 LEGO blocks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages