Skip to contents

Generates a content-based fingerprint for duplicate detection and authenticity verification. Use this during artwork upload to detect duplicates before accepting new submissions, or to verify that a displayed image matches the registered original.

Store the returned `art_hash` and `art_binary` in the database for future comparisons. The binary form enables Hamming distance calculations to find visually similar images (distance < 10 indicates high similarity).

Usage

image_phash(path)

Arguments

path

Character. Path to image file - accepts local filesystem paths or URLs. For local paths, must be absolute or relative to working directory. For URLs, supports HTTP/HTTPS (e.g., CDN URLs from `artutils::pathArtImage()`). File must exist and be a supported image format (PNG, JPEG, WebP, etc.).

Value

List with two elements:

art_hash

12-character perceptual hash string for quick lookups

art_binary

64-character binary string for Hamming distance similarity comparison

Details

Perceptual hashing creates a fingerprint based on image content, not pixel-exact data. Similar images produce similar hashes, enabling fuzzy matching and duplicate detection.

The function: 1. Reads image from path/URL 2. Converts to grayscale JPEG 3. Computes DCT-based perceptual hash 4. Returns both hash and binary forms

Binary form is used for Hamming distance calculation when comparing similarity between images.

See also

Other image-verify: isCanvasSigned()

Examples

if (FALSE) { # \dontrun{
# Hash local image
hash <- image_phash("path/to/image.png")
hash$art_hash # "a1b2c3d4e5f6"
hash$art_binary # "110100101001..."

# Hash image from CDN URL
hash <- image_phash(artutils::pathArtImage(artist, artwork))

# Compare two images by Hamming distance
hash1 <- image_phash("image1.png")
hash2 <- image_phash("image2.png")
# Lower distance = more similar (< 10 is very similar)
} # }