MCPcopy Index your code
hub / github.com/corona10/goimagehash

github.com/corona10/goimagehash @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
74 symbols 220 edges 17 files 42 documented · 57% 4 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GitHub Action GoDoc Go Report Card

goimagehash

Inspired by imagehash

A image hashing library written in Go. ImageHash supports: * Average hashing * Difference hashing * Perception hashing * Wavelet hashing [TODO]

Installation

go get github.com/corona10/goimagehash

Special thanks to

Usage

func main() {
        file1, _ := os.Open("sample1.jpg")
        file2, _ := os.Open("sample2.jpg")
        defer file1.Close()
        defer file2.Close()

        img1, _ := jpeg.Decode(file1)
        img2, _ := jpeg.Decode(file2)
        hash1, _ := goimagehash.AverageHash(img1)
        hash2, _ := goimagehash.AverageHash(img2)
        distance, _ := hash1.Distance(hash2)
        fmt.Printf("Distance between images: %v\n", distance)

        hash1, _ = goimagehash.DifferenceHash(img1)
        hash2, _ = goimagehash.DifferenceHash(img2)
        distance, _ = hash1.Distance(hash2)
        fmt.Printf("Distance between images: %v\n", distance)
        width, height := 8, 8
        hash3, _ = goimagehash.ExtAverageHash(img1, width, height)
        hash4, _ = goimagehash.ExtAverageHash(img2, width, height)
        distance, _ = hash3.Distance(hash4)
        fmt.Printf("Distance between images: %v\n", distance)
        fmt.Printf("hash3 bit size: %v\n", hash3.Bits())
        fmt.Printf("hash4 bit size: %v\n", hash4.Bits())

        var b bytes.Buffer
        foo := bufio.NewWriter(&b)
        _ = hash4.Dump(foo)
        foo.Flush()
        bar := bufio.NewReader(&b)
        hash5, _ := goimagehash.LoadExtImageHash(bar)
}

Release Note

v1.1.0

  • The performance of Perceptionhash is enhanced.

v1.0.3

  • Add workflow for GithubAction
  • Fix typo on the GoDoc for LoadImageHash

v1.0.2

  • go.mod is now used for install goimagehash

v1.0.1

  • Perception/ExtPerception hash creation times are reduced

v1.0.0

IMPORTANT goimagehash v1.0.0 does not have compatible with the before version for future features

v0.3.0

  • Support DifferenceHashExtend.
  • Support AverageHashExtend.
  • Support PerceptionHashExtend by @TokyoWolFrog.

v0.2.0

  • Perception Hash is updated.
  • Fix a critical bug of finding median value.

v0.1.0

  • Support Average hashing
  • Support Difference hashing
  • Support Perception hashing
  • Use bits.OnesCount64 for computing Hamming distance by @dominikh
  • Support hex serialization methods to ImageHash by @brunoro

Core symbols most depended-on inside this repo

Distance
called by 20
imagehash.go
Bits
called by 15
imagehash.go
ToString
called by 7
imagehash.go
ExtPerceptionHash
called by 6
hashcompute.go
NewImageHash
called by 6
imagehash.go
ExtAverageHash
called by 5
hashcompute.go
leftShiftSet
called by 5
imagehash.go
Rgb2Gray
called by 5
transforms/pixels.go

Shape

Function 56
Method 13
Struct 4
TypeAlias 1

Languages

Go100%

Modules by API surface

imagehash.go24 symbols
hashcompute_test.go10 symbols
transforms/pixels.go8 symbols
transforms/static.go6 symbols
hashcompute.go6 symbols
transforms/dct.go4 symbols
imagehash_test.go4 symbols
etcs/utils.go4 symbols
transforms/dct_test.go2 symbols
etcs/utils_test.go2 symbols
imagehash19.go1 symbols
imagehash18.go1 symbols

For agents

$ claude mcp add goimagehash \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact