POST/image

Compare Images

Compute a visual diff between two images. Supports both multipart/form-data file uploads and JSON with base64-encoded data URLs.

Parameters

emailquerystring

Your email address. Required if not using an API key.

input_typequerystringrequired

Specifies the request content-type. - `form`: multipart/form-data - `json`: application/json

Values: json, form

output_typequerystringrequired

Specifies the type of output you receive in the response body. - `json`: Same PNG you see on the Diffchecker site for image diffs, but embedded in JSON as a data URL (Content-Type: application/json) - `png`: Same PNG you see on the Diffchecker site for image diffs (Content-Type: image/png)

Values: json, png

Request Bodyrequired

left_imagestring (binary)required

Left image file you want to diff. Accepted file extensions include .png, .jpg, .jpeg.

right_imagestring (binary)required

Right image file you want to diff. Accepted file extensions include .png, .jpg, .jpeg.

Responses

Every response includes the X-Credits-Used header. In JSON responses, the same value is also available in the creditsUsed field.

Diff computed successfully.

application/json

creditsUsedintegerrequired

Credits charged for the diff request.

dataUrlstringrequired

Data URL of the diff image (PNG).

diffPixelsintegerrequired

Number of pixels that differ.

totalPixelsintegerrequired

Total number of pixels compared.

misMatchPercentagenumber (float)required

Percentage of pixels that differ.

widthintegerrequired
heightintegerrequired
originalWidthintegerrequired
originalHeightintegerrequired
changedWidthintegerrequired
changedHeightintegerrequired
Example
{
  "creditsUsed": 1,
  "dataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABVAAAAS8CAYAAABqj6EYAAAABmJLR0QA...",
  "diffPixels": 34651,
  "totalPixels": 234600,
  "misMatchPercentage": 14.77,
  "width": 460,
  "height": 510,
  "originalWidth": 452,
  "originalHeight": 477,
  "changedWidth": 460,
  "changedHeight": 510
}

image/png

string (binary)

Example Request

curl
curl -X POST \
  "https://web.preview.diffchecker.com/api/public//image?email=your%40email.com&input_type=json&output_type=json" \
  -H "Content-Type: application/json" \
  -d '{
  "left_image": "{left_image}",
  "right_image": "{right_image}"
}'

Try It