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.
$ go get github.com/winhtaikaung/go-legofy
//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)
}
https://godoc.org/github.com/winhtaikaung/go-legofy/legofy
If you find a bug:
- Check in the open issues if the bug already exists.
- If the bug is not there, create a new issue with clear steps on how to reproduce it.
- Image Palette
- Fork it ( https://github.com/winhtaikaung/go-legofy )
- Create your feature branch (
git checkout -b my-new-feature
)
- Commit your changes (
git commit -am 'Add some feature'
)
- Push to the branch (
git push origin my-new-feature
)
- Create a new Pull Request
MIT