-
-
Notifications
You must be signed in to change notification settings - Fork 172
/
icoparser.go
33 lines (29 loc) · 667 Bytes
/
icoparser.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
package main
import (
"fmt"
"os"
"github.com/mat/besticon/ico"
)
func main() {
for _, filename := range os.Args[1:] {
fmt.Printf("%s: ", filename)
f, err := os.Open(filename)
if err != nil {
fmt.Printf("failed to open %s\n", filename)
continue
}
defer f.Close()
dir, err := ico.ParseIco(f)
if err != nil {
fmt.Printf("Failed to parse %s as icon file\n", filename)
} else if dir.Count == 1 {
fmt.Printf("MS Windows icon resource - 1 icon\n")
} else {
best := dir.FindBestIcon()
fmt.Printf("MS Windows icon resource - %d icons, %dx%d, %d-colors\n", dir.Count,
best.Width,
best.Height,
best.ColorCount())
}
}
}