Documentation
¶
Overview ¶
Go implementation of blockhash (http://blockhash.io), a perceptual hash of images
Reference implementation: https://github.com/commonsmachinery/blockhash-python/tree/0d76144cf5b6ac149ff7612ab433a48b0fb9139b
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash struct {
// bit representation of the hash
Bits []int
}
func Blockhash ¶
Generates the block hash for a given image `bits` should be a power of 2 number (e.g. 2, 4, 8, 16, etc.); the number of output bits is equal to bits^2
Example ¶
reader, err := os.Open(defaultFile) // Get the file reader for the image
if err != nil {
log.Fatal(err)
}
hash, _ := Blockhash(reader, 16) // Divide the image into 16x16 blocks, and calculate the hash
fmt.Println("Bits", hash.Bits[:32]) // You should use the entire content in `Bits` though
fmt.Println("Hex", hash.ToHex())
Output: Bits [1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0] Hex 801e3818fd80ffecfffc0ffc0e38000899ff193c1d38083c5c6c9e781e310fb0
Click to show internal directories.
Click to hide internal directories.