Analyse and compare images with Javascript and HTML5. Read the doc here. Compatible with Node.js >8.
Clone this repo or use our docker image : cashstory/resemble-api
Run the docker machine the service is serve on the port 3000 .
do npm i
and then npm start
make it serve on port 3000 .
the API is pretty simple :
POST on /diff
your two images named image_1
and image_2
in option in the body you can use all options of Rasemble.js
curl --location --request POST 'localhost:3000/diff' \
--form 'image_1=@/Users/martind/Downloads/accounting_101_Evolution_du_CA.png' \
--form 'image_2=@/Users/martind/Downloads/accounting_101_Evolution_du_CA_1.png'
or POST with specific options (optional):
curl --location --request POST 'localhost:3000/diff' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--form 'image_1=@/Users/martind/Downloads/accounting_101_Evolution_du_CA.png' \
--form 'image_2=@/Users/martind/Downloads/accounting_101_Evolution_du_CA_1.png' \
--form 'options={
"output": {
"errorColor": {
"red": 255,
"green": 0,
"blue": 255
},
"errorType": "movement",
"transparency": 0.3,
"largeImageThreshold": 1200,
"useCrossOrigin": false,
"outputDiff": true
},
"scaleToSameSize": true,
"ignore": "antialiasing"
}'
the api will return you a JSON object.
like this
{
"diffImage": "BASE64 STRING",
"score": {
"misMatchPercentage": "0.20",
"isSameDimensions": true,
"dimensionDifference": {
"width": 0,
"height": 0
}
}
}
Just ask for the diff score with only=score :
curl --location --request POST 'localhost:3000/diff' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--form 'image_1=@/Users/martind/Downloads/accounting_101_Evolution_du_CA.png' \
--form 'image_2=@/Users/martind/Downloads/accounting_101_Evolution_du_CA_1.png' \
--form 'only=score'
and you get :
{
"misMatchPercentage": "0.14",
"isSameDimensions": true,
"dimensionDifference": {
"width": 0,
"height": 0
}
}
Just ask for the diff image with only=image :
curl --location --request POST 'localhost:3000/diff' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--form 'image_1=@/Users/martind/Downloads/accounting_101_Evolution_du_CA.png' \
--form 'image_2=@/Users/martind/Downloads/accounting_101_Evolution_du_CA_1.png' \
--form 'only=image'
and you get :