Skip to content

Rust + PHP extension

libphp_imagehash

Find visually similar images in PHP at millions-of-image scale.

libphp_imagehash is a native Rust-powered PHP extension for perceptual image hashing. It is designed for projects where exact file matching is not enough.

5Mhashes tested
~550mslimited candidate search
8 bytesper 64-bit perceptual hash
upto x5 Fasterthan similar packages

What can it be used for?

Duplicate detectionFind identical or near-identical images.
Image moderationDetect visually similar images and compare against banlists.
Security researchFind login pages, admin panels and cloned interfaces.
Storage cleanupReduce image duplication without storing full comparisons.

Tiny example

php
$index = new ImageHashIndex();

$index->add('login-page', 'f123456789abcdef');
$index->add('similar-login-page', 'f123456789abcdee');

$matches = $index->search('f123456789abcdef', maxDistance: 5);

print_r($matches);

Expected idea:

php
Array
(
    [0] => Array
        (
            [id] => login-page
            [distance] => 0
        )

    [1] => Array
        (
            [id] => similar-login-page
            [distance] => 1
        )
)
The headline: this is for when you want image similarity search from PHP without doing millions of slow comparisons in userland PHP.

Start here

Native tools, weird experiments, and practical performance work.