imhash

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

README

GO-IMHASH

Calculate perceptual image distance hash in Go.

Requirements

  • ImageMagick convert command line utility

Example

package main

import (
	"fmt"
    "github.com/24HOURSMEDIA/go-imhash"
)

func main() {
    // show hashed values and calculate distance 
	hasher, _ := imhash.CreateService("tom64b")

    imgPath1 := "./image1.jpg"
    imgPath2 := "./image2.jpg"
   
    hash1, _ := hasher.HashFromPath(imgPath1)
    hash2, _ := hasher.HashFromPath(imgPath2)
    fmt.Println(hash1.String())
    fmt.Println(hash2.String())
    fmt.Println(hasher.Distance(hash1, hash2))
    
    // show the population counts
    fmt.Println(hash1.(tom64b_hasher.Hash).PopCount())

}

Tests

go test github.com/24HOURSMEDIA/go-imhash/implementations/tom64b_hasher

Credits

Adapted from: https://github.com/Tom64b/dHash, see:

Foto door Jeremy Bishop via Pexels

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateService

CreateService is a factory method to create a new image hasher service by it's handle.

Types

This section is empty.

Directories

Path Synopsis
implementations
tom64b_hasher
Package tom64b_hasher is a perceptual image hashing Implementation based on the php Implementation at https://github.com/Tom64b/dHash
Package tom64b_hasher is a perceptual image hashing Implementation based on the php Implementation at https://github.com/Tom64b/dHash

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL