Skip to content
/ imghash Public

Perceptual image hashing package for golang.

License

Notifications You must be signed in to change notification settings

ajdnik/imghash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

imghash logo

Go implementation of multiple perceptual hash algorithms for images.

CI status Coverage status Go reference Go report card MIT license

Documentation

Detailed documentation has moved to the Wiki:

Installing

go get -u github.com/ajdnik/imghash/v2
import "github.com/ajdnik/imghash/v2"

Most consumers only need the top-level imghash package. Core types (Hash, Binary, UInt8, Float64, Distance) are re-exported there.

Quick Start

If you're unsure which hash to pick, start with PDQ.

package main

import (
  "fmt"

  "github.com/ajdnik/imghash/v2"
)

func main() {
  pdq, err := imghash.NewPDQ()
  if err != nil {
    panic(err)
  }

  h1, err := imghash.HashFile(pdq, "image1.png")
  if err != nil {
    panic(err)
  }

  h2, err := imghash.HashFile(pdq, "image2.png")
  if err != nil {
    panic(err)
  }

  dist, err := pdq.Compare(h1, h2)
  if err != nil {
    panic(err)
  }

  fmt.Printf("Distance: %v\n", dist)
}

Algorithms at a Glance

Algorithm Hash type Default metric
Average Binary Hamming
Difference Binary Hamming
Median Binary Hamming
PHash Binary Weighted Hamming
WHash Binary Hamming
MarrHildreth Binary Hamming
BlockMean Binary Hamming
PDQ Binary Hamming
RASH Binary Hamming
ColorMoment Float64 L2 (Euclidean)
Zernike Float64 L2 (Euclidean)
GIST Float64 Cosine
BoVW (Histogram) Float64 Cosine
BoVW (MinHash) Float64 Jaccard
BoVW (SimHash) Binary Jaccard
CLD UInt8 L2 (Euclidean)
EHD UInt8 L1 (Manhattan)
LBP UInt8 Chi-Square
HOGHash UInt8 Cosine
RadialVariance UInt8 L1 (Manhattan)

See Algorithms for options, defaults, references, and examples.

Community

License

Imghash is released under the MIT license. See LICENSE.

About

Perceptual image hashing package for golang.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •