dhash
dHash algorithm in Go
Install
go get github.com/guilhermehn/dhash
Or with gopkg:
go get gopkg.in/guilhermehn/dhash.v1
Usage
Two parameters are needed: the path to the image and
the size the image will be resized that will reflect
into the hash final size. The recommended size is 8.
Dhash("image.jpg", 8)
The image will be resized to 8x8 and the hash
size will be size*2 "8899aabbccddeeff"
Example:
package main
import (
"fmt"
"github.com/guilhermehn/dhash"
// or if you installed the gopkg version
// "gopkg.in/guilhermehn/dhash.v1"
)
func main() {
pathToImage := "path/to/image"
detailLevel := 8
hash, err := dhash.Dhash(pathToImage, detailLevel)
if err != nil {
fmt.Println("ERROR: %s", err.Error())
return
}
fmt.Println(hash)
}
Dependencies
License
MIT