# Image Compare – Similarity, Visual Diff & Duplicate Finder (`gazidev/image-compare`) Actor

Compare images in bulk: similarity score, SSIM, pHash, pixel difference % and a visual diff PNG. One image against many, before/after pairs, all pairs, or group duplicate images in a list or dataset. No AI model, no API key. $0.30 per 1,000 comparisons.

- **URL**: https://apify.com/gazidev/image-compare.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 comparisons

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

## Image Compare – Image Similarity, Visual Diff & Duplicate Finder

Compare images in bulk and get numbers you can act on: a **similarity score**, **SSIM**, **perceptual hash distance (pHash and dHash)**, **pixel difference %**, colour difference, the **changed area** and, if you want it, a **visual diff PNG** with every change marked in red. Compare one image with many, before/after pairs, all pairs of a list, or **find and group duplicate images** in a list or an Apify dataset.

**$0.30 per 1,000 comparisons.** No AI model, no API key, no browser. Broken links, non-images and oversized files are free.

### What it does

- **One source vs. many:** is this logo, photo or product picture among these images, and how close is each one?
- **Pairs (before / after):** screenshot and design regression checks, supplier photo vs. shop photo.
- **All pairs:** every combination of up to 200 images.
- **Duplicates:** groups exact copies, the same pixels in another format, resized or re-compressed copies and (optional) rotated or mirrored copies. The best file (most pixels) of every group gets `keep: true`. You pay **per image, not per pair**.
- **Diff images:** `highlight` (changes in red on a faded image), `heatmap` or `side-by-side`.
- **Colour check:** perceptual hashes ignore colour, so a red and a blue version of one product look the same to them. The colour check keeps them apart (you can turn it off).
- **JPG, PNG, WebP, AVIF, HEIC/HEIF, TIFF, GIF, BMP.** EXIF rotation is applied and transparency is shown on white. Links and `data:image/...;base64` URIs both work.

### Input examples

One image against many, with diff pictures:

```json
{
  "sourceImage": "https://example.com/original.jpg",
  "imageUrls": ["https://example.com/copy1.jpg", "https://example.com/copy2.webp"],
  "createDiffImages": true
}
```

Before / after pairs:

```json
{
  "mode": "pairs",
  "pairs": [
    { "before": "https://example.com/home-v1.png", "after": "https://example.com/home-v2.png", "label": "home page" }
  ],
  "compareSize": 2048
}
```

Duplicates in a scraped dataset:

```json
{ "mode": "duplicates", "datasetId": "<dataset id>", "datasetField": "images", "matchThreshold": 6 }
```

Other sources: `bulkText` (one URL per line or CSV; two URLs per line in pairs mode), `sourceFileUrl` (public .txt/.csv) and `datasetFieldB` for pairs stored in a dataset. The `sample://` values in the default input are small pictures inside the Actor, so you can try it with one click.

### Output example

```json
{
  "mode": "one-to-many",
  "imageA": "sample://poster.png",
  "imageB": "sample://poster-edited.png",
  "verdict": "similar",
  "isMatch": true,
  "similarityPercent": 94.81,
  "ssim": 0.9788,
  "pixelDiffPercent": 2.845,
  "colorDifferencePercent": 0.76,
  "psnrDb": 22.85,
  "pHashDistance": 4,
  "dHashDistance": 2,
  "byteIdentical": false,
  "pixelIdentical": false,
  "sameDimensions": true,
  "changedArea": { "x": 150, "y": 408, "width": 459, "height": 55 },
  "diffImageUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/diff-00002.png",
  "widthA": 640, "heightA": 480, "formatA": "png"
}
```

In duplicates mode there is one row per image with `groupId`, `matchType` (`best`, `exact`, `pixel-identical`, `near`, `rotated`, `unique`), `keep`, `isDuplicate` and `bestImageUrl`. The `GROUPS` record lists each group with the file to keep. `SUMMARY` has the totals.

#### How to read the numbers

| Field | Meaning |
|---|---|
| `verdict` | `identical` = same pixels. `near-identical` = SSIM ≥ 0.95 and at most 2% changed pixels (5% when sizes differ). `similar` = pHash distance within `matchThreshold` and similar colours, or SSIM ≥ 0.9. Otherwise `different` |
| `similarityPercent` | 50% SSIM + 30% pHash + 20% colour. Unrelated images usually score 10–50, so use it for ranking, and `verdict` / `isMatch` for decisions |
| `ssim` | Structural similarity of brightness, 1 = identical |
| `pixelDiffPercent` | Share of pixels where a colour channel differs by more than `pixelThreshold` |
| `pHashDistance` | 0–64 different bits. 0–4 = almost surely the same picture, above 12 = usually a different one |
| `changedArea` | Box around all changed pixels, in pixels of image A |

### Pricing

| Event | Price |
|---|---|
| Comparison (one pair; in duplicates mode one image) | $0.0003 ($0.30 per 1,000) |
| Diff image (optional) | $0.001 ($1 per 1,000) |
| Actor start | $0.00005 |

Free: failed downloads, non-images, files above your limits, invalid URLs and repeated URLs. `maxComparisons` (1,000) and `maxDiffImages` (100) guard your budget, and a maximum total charge stops the run cleanly (`SUMMARY.stoppedAtMaxCharge`). For comparison, johnvc/image-similarity-api on the Apify Store charged $0.0005 per comparison in November 2026 (it adds AI embeddings).

### How it differs from our other image Actors

- [Image Metadata & EXIF Extractor](https://apify.com/gazidev/image-metadata-extractor) lists hashes and the first earlier duplicate next to EXIF, GPS and AI signals ($1.50 per 1,000). **This Actor** measures how different two pictures are (SSIM, pixel difference, changed area, diff PNG), works on pairs, and groups duplicates with a file to keep.
- [Image Compressor](https://apify.com/gazidev/image-compressor) and [Image Converter](https://apify.com/gazidev/image-converter) change files; this Actor only compares them. Use it to check their output.
- [Image Downloader](https://apify.com/gazidev/image-downloader) collects the images of a page; pass its dataset here to remove duplicates.

### Limits (honest)

- This is **pixel and hash comparison, not AI**. It finds copies, edits, resized and re-encoded files. It does not know that two different photos show the same person or product, and it does not do face recognition or reverse image search on the web.
- Heavily cropped copies, collages and large overlays usually count as different.
- Very small edits (one digit on a poster) can be `near-identical` or even `similar` at a loose threshold: use `pixelDiffPercent` / `changedArea` when every pixel matters.
- Images of different size are scaled to the smaller one. Different aspect ratios are stretched, which lowers SSIM; the row has a `note`.
- JPEGs above 4 MP are decoded at reduced scale when they are at least three times larger than `compareSize`; `pixelIdentical` then means the same file.
- Only the first frame of animated files is compared. Colour profiles (ICC) are ignored.
- With 512 MB of memory: JPG up to about 50 MP, other formats about 25 MP. Files up to 50 MB.
- Only public addresses are downloaded. Links to private networks are refused, including through redirects. Sites that block cloud servers return an error row (free); no proxy or browser disguise is used.
- Compare only images you are allowed to download and process.

### FAQ

**Is it deterministic?** Yes, the same files and settings give the same numbers.

**Which threshold should I use?** Start with 8. Use 4 for "same picture, re-saved", 12 for loose matching and check the results.

**How do I use it for visual regression tests?** Send the old and new screenshot links as a pair, set `compareSize` to 2048 or more and fail your build when `pixelDiffPercent` is above your limit.

**Are my images stored?** No. They are processed in memory and temporary files of the run. Only the diff PNGs (if enabled) are saved, in your own key-value store.

### Use with AI agents (Apify MCP)

Add this Actor to an MCP client through the Apify MCP server (`https://mcp.apify.com`, tool `gazidev/image-compare`). An agent can send two image links or base64 URIs and read `verdict`, `similarityPercent`, `changedArea` and `diffImageUrl`.

# Actor input Schema

## `mode` (type: `string`):

Automatic: `pairs` filled = pairs; `sourceImage` filled = one-to-many; exactly 2 images = one pair; otherwise duplicates. One-to-many, pairs and all-pairs cost one comparison per pair. Duplicates costs one comparison per image, not per pair.

## `sourceImage` (type: `string`):

Image that is compared with every image in the list below (one-to-many). Direct link, `data:image/...;base64` URI or a built-in `sample://` image. Replace or clear the sample when you use your own images.

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

Direct links to JPG, PNG, WebP, AVIF, HEIC/HEIF, TIFF, GIF or BMP files. `data:image/...;base64` URIs work too. The `sample://` values are small demo images inside the Actor.

## `pairs` (type: `array`):

List of pairs: `[{"a": "https://...", "b": "https://...", "label": "home page"}]`. `before`/`after`, `imageA`/`imageB` and two-element arrays are accepted. Two file links per pair.

## `bulkText` (type: `string`):

One URL per line, or a CSV with a `url` / `image` column. In mode 'pairs': two URLs per line.

## `sourceFileUrl` (type: `string`):

Public .txt or .csv link (Google Sheets 'Publish to web, CSV' works), up to 5 MB. Same format as the bulk list.

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

Chain after a scraper (for example product images).

## `datasetField` (type: `string`):

Dot paths such as `images.0` and arrays of URLs are accepted. In mode 'pairs' this is image A.

## `datasetFieldB` (type: `string`):

When set, each dataset item is one pair: image A from the field above, image B from this field (mode 'pairs' or automatic).

## `matchThreshold` (type: `integer`):

Images count as similar or duplicate when their 64-bit perceptual hashes differ in at most this many bits. 0-4 strict (re-encoded or resized copies), 8 normal, 12+ loose (more false matches).

## `colorSensitive` (type: `boolean`):

Perceptual hashes ignore colour. Keep this on so that a red and a blue version of the same product are not called duplicates.

## `detectRotations` (type: `boolean`):

Also tests image B rotated by 90, 180 and 270 degrees and mirrored. `bestTransform` shows which one matches.

## `pixelThreshold` (type: `integer`):

A pixel counts as changed when any colour channel differs by more than this. 0 = every difference, 25 ignores JPEG noise.

## `compareSize` (type: `integer`):

Images are reduced to this size before SSIM and pixel difference (never enlarged). Use 2048-4096 for full-page screenshots with small text; it is slower.

## `createDiffImages` (type: `boolean`):

Stores a picture of the differences for every pair that is not identical ($0.001 each). Not used in mode 'duplicates'.

## `diffStyle` (type: `string`):

How differences are drawn.

## `maxDiffImages` (type: `integer`):

Spending guard for diff images.

## `maxComparisons` (type: `integer`):

Spending guard for pairs (all pairs of 100 images are 4,950 comparisons).

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

Images above this number are skipped. All-pairs mode always stops at 200 images.

## `maxFileSizeMb` (type: `integer`):

Larger files are reported as TOO_LARGE (free).

## `maxMegapixels` (type: `integer`):

Protects against decompression bombs. With 512 MB of memory: JPG up to about 50 MP, other formats about 25 MP. Larger images are reported for free; run with 1024 MB for them.

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

Lower this if the image host limits requests.

## Actor input object example

```json
{
  "mode": "auto",
  "sourceImage": "sample://poster.png",
  "imageUrls": [
    "sample://poster-resized.jpg",
    "sample://poster-edited.png",
    "sample://other.png"
  ],
  "datasetField": "url",
  "matchThreshold": 8,
  "colorSensitive": true,
  "detectRotations": false,
  "pixelThreshold": 25,
  "compareSize": 1024,
  "createDiffImages": true,
  "diffStyle": "highlight",
  "maxDiffImages": 100,
  "maxComparisons": 1000,
  "maxImages": 1000,
  "maxFileSizeMb": 20,
  "maxMegapixels": 40,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `comparisons` (type: `string`):

No description

## `duplicates` (type: `string`):

No description

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

No description

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

No description

## `summary` (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 = {
    "sourceImage": "sample://poster.png",
    "imageUrls": [
        "sample://poster-resized.jpg",
        "sample://poster-edited.png",
        "sample://other.png"
    ],
    "createDiffImages": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/image-compare").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 = {
    "sourceImage": "sample://poster.png",
    "imageUrls": [
        "sample://poster-resized.jpg",
        "sample://poster-edited.png",
        "sample://other.png",
    ],
    "createDiffImages": True,
}

# Run the Actor and wait for it to finish
run = client.actor("gazidev/image-compare").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 '{
  "sourceImage": "sample://poster.png",
  "imageUrls": [
    "sample://poster-resized.jpg",
    "sample://poster-edited.png",
    "sample://other.png"
  ],
  "createDiffImages": true
}' |
apify call gazidev/image-compare --silent --output-dataset

```

## MCP server setup

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

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/XCygM01zMDF3gGrsb/builds/q6nqZf4t6ViPZtDmQ/openapi.json
