avatar

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package avatar provides perceptual hashing for profile avatars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(a, b uint64) int

Distance returns the hamming distance between two hashes.

func Hash

func Hash(ctx context.Context, cache httpcache.Cacher, avatarURL string, logger *slog.Logger) uint64

Hash fetches an avatar image and computes its perceptual hash. Returns 0 on any error (network, decode, unsupported format). Uses the provided cache for both HTTP responses and computed hashes.

func Score

func Score(a, b uint64) float64

Score returns a similarity score (0.0-1.0) based on hamming distance. Returns 0 if either hash is 0 or distance exceeds threshold.

func Similar

func Similar(a, b uint64) bool

Similar returns true if two avatar hashes are perceptually similar. A hamming distance of 10 or less (out of 64 bits) indicates similarity.

Types

This section is empty.

Jump to

Keyboard shortcuts

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