# Duplicate Image Finder – Detect Repeated and Similar Photos (`mauberme/image-dedup`) Actor

Find photos that are the same picture even when resized or saved again at a different quality. Paste image links or connect the results of any scraper, and get groups of duplicates with the best copy of each to keep. Free during launch.

- **URL**: https://apify.com/mauberme/image-dedup.md
- **Developed by:** [Mauberme](https://apify.com/mauberme) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Image Finder – Detect Repeated and Similar Photos

**What is it for?** Photo galleries and scraped product images are full of repeats: the same picture uploaded twice, at a smaller size, or saved again at lower quality. This tool **finds those repeats even when the files are not identical**, groups them, and tells you **which copy to keep** (the largest one). Paste image links, or plug in the results of any other Apify scraper.

Find **duplicate and near-duplicate images** in a list of URLs or in the dataset of any scraper.
Input: image URLs (or an Apify **dataset ID** + the field that holds the image URL). Output: one row
per image with its **perceptual hash (pHash)**, size, **duplicate group**, whether it is a duplicate
and **which copy to keep** (the highest resolution one), plus a summary with the list of unique
images. Catches copies that byte-level checksums miss: **resized, recompressed, re-encoded
(JPEG ↔ WebP ↔ PNG) or lightly edited** versions of the same picture.

### Clean the images your scraper collected

Scraped product catalogs, real-estate listings, marketplaces and social feeds are full of the same
photo at different sizes and URLs. Run this Actor right after your scraper:

```json
{
  "datasetId": "<default dataset ID of your scraper run>",
  "imageUrlField": "images",
  "threshold": 5
}
```

- `imageUrlField` accepts dot paths (`product.image.url`, `images.0`) and expands arrays of URLs or
  of `{ "url": … }` / `{ "src": … }` objects.
- Chain it in an Apify integration / webhook ("run after scraper succeeds") and pass the run's
  `defaultDatasetId`.
- Use `OUTPUT.keptUrls` from the key-value store to download only the unique, best-quality images.

### Input example (plain URLs)

```json
{
  "imageUrls": [
    "https://picsum.photos/id/10/1600/1000",
    "https://picsum.photos/id/10/400/250",
    "https://picsum.photos/id/20/1200/800"
  ],
  "threshold": 5,
  "maxImages": 1000,
  "maxImageSizeMb": 20
}
```

| Field | Default | Notes |
|---|---|---|
| `imageUrls` | — | Public http(s) image URLs |
| `datasetId` / `imageUrlField` | — / `imageUrl` | Read URLs from an Apify dataset (combinable with `imageUrls`) |
| `threshold` | `5` | Max Hamming distance (0–20 of 64 bits). 0 = identical, 5 = resized/recompressed copies, 10+ = looser |
| `maxImages` | `1000` | Hard cap 5000 |
| `maxImageSizeMb` | `20` | Hard cap 50 |

### Output example

Dataset, one row per image:

```json
{
  "url": "https://picsum.photos/id/10/400/250",
  "hash": "ab4cd46c4b334726",
  "width": 400,
  "height": 250,
  "groupId": "g0001",
  "groupSize": 2,
  "isDuplicate": true,
  "keptUrl": "https://picsum.photos/id/10/1600/1000",
  "distance": 1,
  "error": null
}
```

- `isDuplicate: false` → this is the copy to keep (unique images are their own group).
- `keptUrl` → the best copy of the group: highest resolution, then biggest file.
- `distance` → Hamming distance to the kept copy (0 = identical hash).
- Images that could not be downloaded or decoded get a row with `error` and the run continues.

Key-value store `OUTPUT` (summary):

```json
{
  "totalUrls": 3, "analyzedImages": 3, "failedImages": 0, "notProcessedDueToSpendingLimit": 0,
  "threshold": 5, "groups": 2, "duplicateGroups": 1, "duplicates": 1, "uniqueImages": 2,
  "keptUrls": ["…"], "duplicateUrls": ["…"]
}
```

### How it works

pHash (DCT-based, 64 bits): each image is EXIF-rotated, converted to greyscale, resized to 32×32,
transformed with a 2D DCT and the 8×8 low-frequency block is thresholded against its mean. Similar
pictures produce hashes with a small Hamming distance. Images closer than `threshold` are linked
(single linkage: if A≈B and B≈C they share a group).

### Pricing

**Free during launch.** This Actor has no usage fee of its own: you only pay Apify's standard platform usage for your runs (on the free Apify plan that is covered by your monthly credit). A pay-per-result price may be introduced later; Apify notifies users in advance of any price change.

### Limits

- Up to 5000 images per run (`maxImages`), 50 MB per image (`maxImageSizeMb`, default 20 MB),
  100 megapixels per image.
- Only public `http`/`https` URLs; internal network addresses are refused. No login or cookies.
- Exact duplicate URLs in the input are analyzed once.
- Perceptual hashing detects the *same picture*: it does not match crops that remove much of the
  image, mirrored/rotated copies or "similar but different" photos (e.g. two shots of the same scene
  may or may not match depending on `threshold`).
- Comparison is all-pairs (O(n²)); fine up to the 5000-image cap.

# Actor input Schema

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

Public http(s) URLs of images (JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG). Optional if you use a dataset below.

## `datasetId` (type: `string`):

Clean the images your scraper collected: ID or name of an Apify dataset (e.g. the default dataset of a previous run). Image URLs are read from the field below.

## `imageUrlField` (type: `string`):

Field of each dataset item holding the image URL. Dot paths work ("product.image", "images.0"). Arrays of URLs or of {url|src} objects are expanded.

## `threshold` (type: `integer`):

Max number of differing bits (out of 64) to treat two images as duplicates. 0 = identical hashes only; 5 = resized/recompressed copies (recommended); 10+ = looser, more false positives.

## `maxImages` (type: `integer`):

Cap on images analyzed per run. Hard cap: 5000.

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

Larger downloads are skipped with an error row. Hard cap: 50 MB.

## Actor input object example

```json
{
  "imageUrls": [
    "https://picsum.photos/id/10/1600/1000",
    "https://picsum.photos/id/10/400/250",
    "https://picsum.photos/id/20/1200/800"
  ],
  "imageUrlField": "imageUrl",
  "threshold": 5,
  "maxImages": 1000,
  "maxImageSizeMb": 20
}
```

# Actor output Schema

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

No description

## `summary` (type: `string`):

No description

## `files` (type: `string`):

No description

# 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://picsum.photos/id/10/1600/1000",
        "https://picsum.photos/id/10/400/250",
        "https://picsum.photos/id/20/1200/800"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mauberme/image-dedup").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://picsum.photos/id/10/1600/1000",
        "https://picsum.photos/id/10/400/250",
        "https://picsum.photos/id/20/1200/800",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("mauberme/image-dedup").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://picsum.photos/id/10/1600/1000",
    "https://picsum.photos/id/10/400/250",
    "https://picsum.photos/id/20/1200/800"
  ]
}' |
apify call mauberme/image-dedup --silent --output-dataset

```

## MCP server setup

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

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/apO4VcyY0bODUPQiW/builds/K3hjK42hn3cB4RWdC/openapi.json
