Free plan

Compare Images

Find what is different between two pictures
POST
/v1/images/compare

About this tool

Compares two pictures and tells you how different they are, with a score and a match answer. It also makes a picture that paints the changed places in colour. If the pictures have different sizes, the second is resized to fit the first. You can limit the check to one area or split it into a grid.
For example, you compare two versions of a web page screenshot to spot what changed.

How to use it

  1. Choose this tool.
  2. Add the first picture in the first box.
  3. Add the second picture in the second box.
  4. Choose how sensitive the check should be, then press Generate.
  5. Read the scores and download the picture that marks the differences.

What you get back

You get scores that say how different the pictures are, and a new picture with the differences painted in colour.
GOOD TO KNOW
A comparison counts as one file. The `hash` metric is a 64-bit difference hash: it survives re-compression and resizing, so it answers "is this the same picture" rather than "are the pixels equal". The images must each be at most 50 megapixels.
TEST IT LIVE

Try Compare Images in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Images
Plan
Free
Method
POST
Endpoint
/v1/images/compare
Tool ID
images.compare
Authentication
API key
Accepts
JPEG, PNG, WEBP, GIF, AVIF, TIFF +15 more
Background jobs
Yes
Usage group
Image
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/images/compare" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'imageA=@photo.jpg' \
  -F 'imageB=@photo.jpg' \
  -F 'threshold=0.1' \
  -F 'alpha=0.1' \
  -F 'max_diff_ratio=0'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.images.compare({
    "imageA": 'photo.jpg',
    "imageB": 'photo.jpg',
    "threshold": 0.1,
    "alpha": 0.1,
    "max_diff_ratio": 0
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->images()->compare([
    'imageA' => 'photo.jpg',
    'imageB' => 'photo.jpg',
    'threshold' => 0.1,
    'alpha' => 0.1,
    'max_diff_ratio' => 0,
]);
echo $result->requestId;
FAQ

Frequently asked questions

How different are two images, and where? Reports the share of differing pixels (anti-aliasing aware), structural similarity (SSIM), a perceptual-hash distance and PSNR, can limit the comparison to a region or break the difference down per grid cell, and returns a diff image that paints what changed. Images of different sizes are scaled to each other first (`resize_to`). `match` tells whether the difference stays within `max_diff_ratio`.

Compare Images accepts JPEG, PNG, WEBP, GIF, AVIF, TIFF, SVG, SVGZ, BMP, ICO, APNG, PNM and 9 more. Send one file per request.

Compare Images is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/images/compare with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.