API reference
This page is intentionally simple for now. Replace with generated stubs later if preferred.
ImageHashIndex
Main in-memory index.
php
$index = new ImageHashIndex();add()
Add a precomputed hash.
php
$index->add(string $id, string $hash): voidExample:
php
$index->add('image-1', 'f123456789abcdef');search()
Search by hash.
php
$index->search(string $hash, int $maxDistance = 10, int $limit = 10): arrayExample:
php
$matches = $index->search('f123456789abcdef', maxDistance: 5, limit: 20);save()
Save the index to disk.
php
$index->save(string $path): voidload()
Load a saved index.
php
$index = ImageHashIndex::load(string $path);Result shape
Expected result shape:
php
[
[
'id' => 'image-1',
'distance' => 0,
],
[
'id' => 'image-2',
'distance' => 2,
],
]