Пример #1
0
func main() {

	if len(os.Args) != 2 {
		fmt.Fprintf(os.Stderr, "USAGE command imagepath")
		os.Exit(1)
		return
	}

	filename := os.Args[1]
	_, err := os.Stat(filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "File not found: %v", err)
		os.Exit(1)
		return
	}

	h, err := phash.ImageHashDCT(filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error calculating phash: %v", err)
		os.Exit(1)
		return
	}

	fmt.Fprintf(os.Stdout, "%v", h)

}
Пример #2
0
func main() {

	h1, err := phash.ImageHashDCT(os.Args[1])
	if err != nil {
		fmt.Println(err)
		return
	}

	h2, err := phash.ImageHashDCT(os.Args[2])
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("h1: ", h1)
	fmt.Println("h2: ", h2)
	fmt.Println("distance: ", phash.HammingDistance(h1, h2))

}