-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
35 lines (30 loc) · 823 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
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, 30, 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, 30, imgChanel)
img = <-imgChanel
close(imgChanel)
legofy.SaveAsPNG("lego_with_img", img.Image, png.BestCompression)
}