Giter VIP home page Giter VIP logo

resemble-api's Introduction

Resemble.js

Build Status Code Health Coverage Build Status NPM Downloads

Analyse and compare images with Javascript and HTML5. Read the doc here. Compatible with Node.js >8.


Get it

Clone this repo or use our docker image : cashstory/resemble-api

Docker

Run the docker machine the service is serve on the port 3000 .

Local

do npm i and then npm start make it serve on port 3000 .

Test it

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
        }
    }
}

Only option

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 :

Diff Image exemple

resemble-api's People

Contributors

bobcashstory avatar riderx avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.