Bulk Image Comparison API: Visual Diff & Similarity Score
Pricing
from $0.39 / 1,000 image pair compareds
Bulk Image Comparison API: Visual Diff & Similarity Score
Compare baseline and candidate images in bulk. Get SSIM, perceptual hash distances, pixel diff percentage, changed-region boxes, a diff overlay PNG and a pass/fail verdict per pair. Set thresholds, ignore regions and handle size differences.
Pricing
from $0.39 / 1,000 image pair compareds
Rating
0.0
(0)
Developer
bite-sized-insights
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
6 days ago
Last modified
Categories
Features
Share
Compare images in bulk with a visual diff and similarity score. Give it baseline/candidate pairs (URLs or base64) and get back an SSIM score, perceptual hash distances, the share of changed pixels, bounding boxes of the changed regions, a diff overlay image and a pass/fail verdict, from $0.60 per 1,000 pairs (failed pairs are free).
Typical uses:
- Visual regression testing: compare screenshots before and after a deploy and fail the build on unwanted changes.
- Design review: catch unintended layout, colour or text changes between two versions of a page or asset.
- Near-duplicate detection: find images that look the same despite resizing or re-compression.
- Re-encode checks: verify that a converted or compressed image still looks the same as the original.
How to compare images
- Click Try for free and add your pairs. Each pair has a
baselineand acandidate, as a URL, a data URI or raw base64. - Set
similarityThreshold(default 0.98). Optionally addmaxDiffPercentandignoreRegionsfor areas such as ads or timestamps. - Run the Actor. It returns one dataset item per pair, in input order.
- Read
passedfor the verdict,ssimandpixel_diff_percentfor the numbers, and opendiff_image_urlto see exactly what changed.
Input
{"pairs": [{"baseline": "https://example.com/before.png","candidate": "https://example.com/after.png","label": "Home page","ignoreRegions": [{ "x": 0, "y": 0, "width": 300, "height": 90 }]}],"similarityThreshold": 0.98}
| Field | Description |
|---|---|
pairs | Up to 500 pairs: baseline and candidate (URL or base64), optional label and ignoreRegions |
similarityThreshold | Minimum SSIM score to pass (default 0.98) |
maxDiffPercent | Optional: also fail when more than this percentage of pixels changed |
pixelTolerance | Per-channel colour difference (0 to 255) still treated as unchanged (default 10) |
resizeMode | Resize the candidate to the baseline size (default), or report an error when the sizes differ |
maxDimension | Larger images are scaled down for the comparison (default 1600, up to 4000) |
normalize | Optionally stretch contrast or convert to grayscale before comparing |
ignoreRegions | Areas to skip (ads, timestamps, carousels) in baseline pixels, applied to every pair |
createDiffImage | Store the diff overlay and return its link (default true) |
Ignored areas are excluded from the score, the changed-pixel percentage and the regions.
Images as URL or base64
Each image can be an http(s) URL, a base64 data URI or a raw base64 string, and the two images of a pair can use different forms:
{"pairs": [{ "baseline": "https://example.com/before.png", "candidate": "data:image/png;base64,iVBORw0KGgo..." },{ "baseline": "iVBORw0KGgoAAAANSUhEUg...", "candidate": "https://example.com/after.png" }]}
- Detection:
http://orhttps://is a URL,data:is a data URI, anything else is raw base64. Other schemes (ftp://,file://) are rejected. - Data URIs must look like
data:image/<format>;base64,<data>. The media type is not trusted: the image is always decoded and checked, so adata:image/pngURI holding a JPEG still works. - Encoding: standard or URL-safe alphabet (not mixed). Spaces and line breaks are ignored and missing
=padding is added. Wrong padding and any other character are rejected. - Prefer URLs for large images. Base64 travels inside the run input, and the Apify platform limits the size of the input (a few MB in total), so a handful of screenshots fits but large files or many pairs do not. Upload files to a key-value store and pass their URLs instead.
- Base64 inputs are never fetched, and the data is never copied into the results or logs.
Output
One dataset item per pair, in input order.
{"index": 1,"label": "Home page","baseline_url": "https://example.com/before.png","baseline_input": "https://example.com/before.png","candidate_url": null,"candidate_input": "base64 image (48213 bytes)","passed": false,"ssim": 0.9412,"phash_distance": 4,"pixel_diff_percent": 2.31,"region_count": 1,"regions": [{ "x": 120, "y": 340, "width": 420, "height": 96, "changed_pixels": 8120 }],"diff_image_url": "https://api.apify.com/v2/key-value-stores/.../records/diff-00001.png"}
A pair that matches looks like this (shortened):
{ "index": 2, "label": "Pricing page", "passed": true, "ssim": 0.9996, "phash_distance": 0,"pixel_diff_percent": 0.0, "region_count": 0, "regions": [], "error": null }
| Field | Description |
|---|---|
index, label | 1-based position of the pair and the label you gave it |
passed | true when ssim reaches similarityThreshold and any maxDiffPercent is respected; null on error |
ssim | Structural similarity, 0 to 1 (1 is identical) |
phash_distance, ahash_distance, dhash_distance | Perceptual hash Hamming distances, 0 to 64 (0 is identical) |
pixel_diff_percent, changed_pixels | Share and number of pixels that differ beyond pixelTolerance |
region_count, regions | Changed areas (x, y, width, height, changed_pixels) in baseline pixels |
baseline_size, candidate_size, compared_size | Original sizes and the size used for the comparison |
diff_image_url, diff_image_key | Diff overlay PNG (changes in red, regions outlined) and its store key |
baseline_url, candidate_url | URL as given, null for base64 images |
baseline_input, candidate_input | URL as given, or a label like base64 image (48213 bytes); no data echoed |
error | Why the pair could not be compared, otherwise null |
Pairs that cannot be compared (unreachable URL, download timed out, invalid base64, not an image, file too large) are returned with an error message and no scores, and are not charged.
Pricing
Pay per event, with no subscription:
- $0.00005 per run start.
- $0.60 per 1,000 compared pairs ($0.0006 each). Failed pairs are free.
Price per compared pair by Apify subscription plan (applied automatically; Gold, Platinum and Diamond share one price):
| Event | Free | Bronze | Silver | Gold+ |
|---|---|---|---|---|
| Compared pair | $0.0006 ($0.60 per 1,000) | $0.00057 ($0.57 per 1,000) | $0.00051 ($0.51 per 1,000) | $0.00039 ($0.39 per 1,000) |
The price depends on your Apify subscription plan and applies automatically, with no setting needed.
Example: 500 pairs that all compare successfully cost 500 x $0.0006 + $0.00005 = $0.30005. If 20 of them fail to download, you pay for 480 pairs. Runs on the free plan and test runs compare the first 10 pairs, so you can try the Actor before paying.
Limits
| Limit | Value |
|---|---|
| Pairs per run | 500 (10 on the free plan and in test runs) |
| Image size | 25 MB per image, also for decoded base64 |
| Download time | 90 seconds per image URL in total, including redirects; slower downloads are reported as an error |
| Image dimensions | 36 million pixels per image |
| Formats | PNG, JPEG, WebP, GIF (first frame), BMP, TIFF; transparency is flattened onto white |
| URLs | Public http(s) only; private and local addresses are refused |
| Base64 | Counts toward the Apify run input size limit, so prefer URLs for large images |
Oversized files are rejected before they are decoded. Pairs beyond the free-plan cap, and pairs not started once your spending limit is reached, produce no dataset item, and neither do pairs not started because the run was stopped or migrated; compare index with your input to spot them. A pair that cannot finish before the run's time limit is not started and gets an item with the error time_limit: not started, not enough time left in this run; it is free, so run it again in a new run. Run-level and pair-level ignoreRegions together may not exceed 100 per pair.
Use from the API
Start a run with the Apify API or a client library. Python:
from apify_client import ApifyClientclient = ApifyClient("<APIFY_TOKEN>")run = client.actor("wdm83jKxrIp1ndxgi").call(run_input={"pairs": [{"baseline": "https://example.com/before.png", "candidate": "https://example.com/after.png"}],"similarityThreshold": 0.98,})items = client.dataset(run["defaultDatasetId"]).list_items().itemsif not all(item["passed"] for item in items):raise SystemExit("Visual regression detected")
JavaScript:
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: '<APIFY_TOKEN>' });const run = await client.actor('wdm83jKxrIp1ndxgi').call({pairs: [{ baseline: 'https://example.com/before.png', candidate: 'https://example.com/after.png' }],});const { items } = await client.dataset(run.defaultDatasetId).listItems();if (items.some((item) => !item.passed)) process.exit(1);
The non-zero exit makes the script usable as a step in a CI pipeline.
FAQ
Which score should I use? SSIM is the best single measure of how different two images look. Use the hash distances to find near-duplicates regardless of size or compression, and the pixel diff and regions to see exactly what changed.
What threshold should I choose? The default 0.98 flags small but visible changes. Lower it (for example to 0.95) if anti-aliasing or font rendering differences cause false alarms, or raise it for pixel-exact checks. Adding maxDiffPercent gives a second, independent limit.
Why does a one-pixel shift fail? SSIM compares local structure, so a shifted edge or text line changes the score even though the images look alike. Perceptual hashes tolerate small shifts, so check phash_distance as well.
My screenshots differ in height. With the default resize mode the candidate is scaled to the baseline size before comparing. Choose the error mode if a size change should count as a failure.
How do I ignore ads, timestamps or carousels? Set ignoreRegions on the pair or at the top level, in baseline pixels. Those areas are excluded from the score, the changed-pixel percentage and the regions.
What happens with animated GIFs? Only the first frame is compared.
Do images have to be public? The Actor downloads URLs without a login, so they must be reachable publicly. For private images, send them as base64 or upload them to a public key-value store.
Is my image data stored? Base64 data is never echoed into results or logs, and failed pairs drop their payload. The diff overlay is the only image the Actor stores, in the run's key-value store.
What happens when the run's time limit is close? Pairs that cannot finish in the remaining time are not started and are reported with a time_limit error instead of being cut off half way. Results already produced are kept and only compared pairs are charged.
What do I pay for failed pairs? Nothing. Only successfully compared pairs are charged.
Related Actors
- Website Screenshot API - Screenshots as visual records of pages.
- Image Compressor & Resizer - Batch-optimize image libraries.
- convert web pages to PDF - Print-ready PDFs from any URL or HTML.
Support
Found a bug or need a feature? Open an issue in the Issues tab of this Actor.