/
main.go
52 lines (41 loc) · 849 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"flag"
"os"
"github.com/nishkarr/sqrizr/sqrizrlib"
)
var (
srcImagePath string
)
func main(){
flag.StringVar(&srcImagePath, "src", "", "Source image path")
flag.Parse()
if srcImagePath == "" {
fmt.Println("Missing parameters")
flag.PrintDefaults()
return
}
var (
err error
srcImageFile, outputFile *os.File
)
srcImageFile, err = os.Open(srcImagePath)
if err != nil {
fmt.Println(err)
return
}
defer srcImageFile.Close();
outputFile, err = os.Create("output.png")
if err != nil {
fmt.Println(err)
return
}
defer outputFile.Close()
format, orientation, err := sqrizrlib.Sqrize(srcImageFile, outputFile)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(fmt.Sprintf("processed file: %s\nformat: %s\norientation: %s", srcImagePath, format, orientation))
}