# Duplicate & Similar Image Finder (Perceptual Hash) (`chivalrous_skyline_vtd/image-duplicate-finder`) Actor

Find exact and near-duplicate images in a list of URLs with perceptual hashing. Groups resized, recompressed and re-saved copies, picks the best one to keep, and flags the rest.

- **URL**: https://apify.com/chivalrous_skyline_vtd/image-duplicate-finder.md
- **Developed by:** [HexaX](https://apify.com/chivalrous_skyline_vtd) (community)
- **Categories:** Developer tools, Other
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 image analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Duplicate & Similar Image Finder (Perceptual Hash)

Find **exact and near-duplicate images** in a list of URLs. It groups copies that were resized, recompressed, converted to another format or lightly edited, picks the **best copy to keep** in each group, and flags the rest.

### What you get

- Groups of the same picture even when the file differs: other size, JPEG vs PNG vs WebP, different compression.
- A **keep / duplicate / unique** status per image, with the URL of the copy to keep.
- The reason for each pick: the copy with the most pixels wins, then the sharpest, then the largest file.
- Per image: width, height, bytes, format, a sharpness score, SHA-256, hash distance to the kept copy, and whether it is a byte-identical copy.
- No AI model and no external service: perceptual hashes (a DCT hash and a gradient hash that must both agree) computed locally.

### Use cases

- Clean up AI-generated batches where similar seeds and re-saves pile up.
- De-duplicate product photos, stock sets and scraped image collections.
- Find lower-resolution copies of the same asset across CDNs and sites.
- Check a gallery for repeated uploads before you publish it.

### Quick start

Keep the example URLs (a photo, an identical copy of it, and two different photos) and press Start. The first two end up in one group; the others are `unique`.

### Input

```json
{
  "imageUrls": ["https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg", "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1"],
  "similarityThreshold": 6
}
```

| Field | Default | Notes |
|---|---|---|
| `imageUrls` | (required) | 2 to 2,000 direct links. |
| `similarityThreshold` | `6` | 0-20, out of 64 hash bits. 0 = identical pixels only. About 6 catches resized and recompressed copies. Above 12 starts to group different pictures. |
| `onlyReportDuplicates` | `false` | Leave `unique` images out of the output. |
| `maxImageSizeMb` | `30` | Larger files are skipped with an error. |
| `maxConcurrency` | `4` | Parallel downloads. |

### Output

```json
{
  "url": "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1",
  "status": "duplicate",
  "group_id": 1,
  "group_size": 2,
  "keep_url": "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
  "distance_to_keep": 0,
  "exact_copy_of_keep": true,
  "width": 640, "height": 480, "bytes": 161713, "format": "jpeg",
  "sharpness": 3007.03
}
```

Rows are ordered group by group (the kept copy first in its group), then unique images, then failures.

### Limits

- Images smaller than 16 px on a side carry too little information for perceptual comparison; they only match byte-identical copies.
- Crops, mirrored copies and heavy edits are different pictures to the hash and are not grouped.
- All images are compared with each other, so very large lists take longer (2,000 images = about 2 million comparisons, done in memory).
- Each site's `robots.txt` is checked before downloading. Use it on images you are allowed to process.

### Pricing

Pay per event: you are charged once per image that was downloaded and analysed. Failed downloads are free.

### Related Actors

- **Bulk Image Compressor & WebP / AVIF Converter**: shrink the images you keep.
- **Image Metadata Remover**: strip EXIF, GPS and AI prompts before publishing.
- **Stable Diffusion Prompt Extractor**: read the prompt and settings embedded in AI images.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to the images to compare (JPEG, PNG, WebP, GIF, BMP), 2 to 2,000 per run. Only images you are allowed to download. Each site's robots.txt is checked first.

## `similarityThreshold` (type: `integer`):

Largest perceptual-hash difference (out of 64 bits) still counted as the same picture. 0 = identical pixels only; about 6 catches resized, recompressed and lightly edited copies; above 12 starts to group different pictures.

## `onlyReportDuplicates` (type: `boolean`):

Leave unique images out of the output. Failed downloads are still listed.

## `maxImageSizeMb` (type: `integer`):

Larger images are skipped with an error.

## `maxConcurrency` (type: `integer`):

Lower this if a site rate-limits you.

## Actor input object example

```json
{
  "imageUrls": [
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0012.jpg",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/Canon_40D.jpg"
  ],
  "similarityThreshold": 6,
  "onlyReportDuplicates": false,
  "maxImageSizeMb": 30,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `results` (type: `string`):

Results in the run's default dataset.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0012.jpg",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/Canon_40D.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("chivalrous_skyline_vtd/image-duplicate-finder").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": [
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0012.jpg",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/Canon_40D.jpg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("chivalrous_skyline_vtd/image-duplicate-finder").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg?copy=1",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0012.jpg",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/Canon_40D.jpg"
  ]
}' |
apify call chivalrous_skyline_vtd/image-duplicate-finder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,chivalrous_skyline_vtd/image-duplicate-finder"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/KtVgkc7E1jqAp9Vc6/builds/dVxyiE4fln3tk8Wvm/openapi.json
