Image Anonymization

FREEMIUM
Door API 4 AI | Bijgewerkt il y a 4 jours | Video, Images
Populariteit

8.8 / 10

Latency

820ms

Serviceniveau

100%

Health Check

100%

Volgers: 1
Bronnen:
Productwebsite
API maker:
Rapid account: API 4 AI
API 4 AI
api4ai
Log in om API te beoordelen
Beoordeling: 4 - Stemmen: 2

README

Endpoints

METHOD URL DESCRIPTION
GET https://image-anonymization.p.rapidapi.com/v1/version Get service version.
GET https://image-anonymization.p.rapidapi.com/v1/modes Get list of available modes.
POST https://image-anonymization.p.rapidapi.com/v1/results Anonymize image and get results.

Get version

Returns an actual version of the service in format vX.Y.Z where X is the version of API.

PROPERTY DESCRIPTION
Endpoint https://image-anonymization.p.rapidapi.com/v1/version
Method GET

Examples

Request:

$ curl -X 'GET' 'https://image-anonymization.p.rapidapi.com/v1/version'

Response:

v1.11.0

Get list of available modes

The service provides serveral modes for image anonymization. This endpoint
returns list of supported modes that can be used as values of mode query parameter
of /results endpoint.

PROPERTY DESCRIPTION
Endpoint https://image-anonymization.p.rapidapi.com/v1/modes
Method GET

Examples

Request:

$ curl -X 'GET' 'https://image-anonymization.p.rapidapi.com/v1/modes'

Response:

[
  "hide-clp",
  "hide-face"
]

Analyse image and return results

Performs actual image analysis and responds with results.

PROPERTY DESCRIPTION
Endpoint https://image-anonymization.p.rapidapi.com/v1/results
Method POST
Query parameters mode
POST parameters image, url

Query parameter mode is optional and may be used to choose which kind of objects to hide. The following modes are supported:

  • hide-clp – to hide car license plates
  • hide-face – to hide faces

Note, the mode query parameter can appear multiple times in a query string. For example, if you want to hide two types of objects at the same time (car license plates and faces) you can add mode=hide-clp&mode=hide-face to a query string.

By default (if mode is not passed via query) all supported objects will be hidden.

Response schema

For responses with 200 HTTP code the type of response is JSON object with the following schema:

{
  "results": [
    {
      "status": {
        "code": ...,
        "message": ...
      },
      "name": ...,
      "md5": ...,
      "page": ...,
      "width": ...,
      "height": ...,
      "entities": [
        {
          "kind": "image",
          "name": "anonymized-image",
          "format": ...
          "image": ...
        },
        {
          "kind": "objects",
          "name": "hidden-objects",
          "objects": [
            {
              "box": ...,
              "entities": [
                {
                  "kind": "classes",
                  "name": "classes",
                  "classes": {
                    ...
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Primary fields:

Name Type Description
results[].status.code string Status code of image processing: ok or failure.
results[].status.message string Human readable explanation for status of image processing.
results[].name string Original image name passed in request (e.g. my_image.jpg).
results[].md5 string MD5 sum of original image passed in request.
results[].page int Optinal page number (presented for multipage inputs only).
results[].width int Optinal image width (presented for valid inputs only).
results[].height int Optinal image height (presented for valid inputs only).
results[].entities[].name string The name of output entity.
results[].entities[].format string The result image format (usually the same as input image format)
results[].entities[].image string PNG or JPEG result image encoded as base64.
results[].entities[].objects array Array of hidden object.
results[].entities[].objects[].box array Object’s bounding box defined by 4 float values.
results[].entities[].objects[].entities[].classes object Object’s classes and confidence of recognition.

The most important part of the response is results[].entities[0].image field.
The result image is an anonymized image encoded as base64.

Also results[].entities[1].objects may be useful if you want to know location of hidden objects. Some details:

  • Bounding box defines location of object in normalized coordinates
    (0.0 – left/top, 1.0 – right/bottom) in the following notations: [x, y, width, height].
  • Besides bounding boxes, detection results contain recognized classes names and confidence (in range from 0.0 to 1.0).

Other fields that are not described above always have the same values.

Passing image

Image can be passed by postint regular “multipart form data” in two alternative ways:

  • as binary file in image field
  • as URL to some public resource in url field

Image must be a regular JPEG or PNG image (with or without transparency) or PDF file.
Usually such images have extensions: .jpg, .jpeg, .png, .pdf. In case of PDF
each page will be converted to PNG image and processed separately.
The service checks input file by MIME type and accepts the following types:

  • image/jpeg
  • image/png
  • application/pdf

The size of image file must be less than 16Mb.

The maximum allowed resolution is 4096x4096.

Examples

Request:

curl -X 'POST' 'https://image-anonymization.p.rapidapi.com/v1/results' -F 'image=@car.jpg'

Response:

{
  "results": [
    {
      "status": {
        "code": "ok",
        "message": "Success"
      },
      "name": "car.jpg",
      "md5": "f2d13d0242b98aae82bc7a6dc76e1ea9",
      "width": 1024,
      "height": 768,
      "entities": [
        {
          "kind": "image",
          "name": "anonymized-image",
          "format": "PNG",
          "image": "iVBORw0KGgoAAAA...YII="
        },
        {
          "kind": "objects",
          "name": "hidden-objects",
          "objects": [
            {
              "box": [
                0.7458327412605286,
                0.6650611162185669,
                0.1188957691192627,
                0.07453817129135132
              ],
              "entities": [
                {
                  "kind": "classes",
                  "name": "classes",
                  "classes": {
                    "License plate": 0.5641241073608398
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Possible errors

The service can not process an image

When client sends an image that can not be processed for some reason(s), the service responds with 200 code and returns JSON object in the same format as the format for successful analysis. In this case, the results[].status.code will have failure value and results[].status.message will contain relevant explanation.

Example of possible reasons for the issue:

  • Unsupported MIME type
  • Image resolution exceeds limits
  • Corrupted image

Example response for image with unsupported MIME type:

{
  "results": [
    {
      "status": {
        "code": "failure",
        "message": "Can not load image."
      },
      "name": "file.txt",
      "md5": "d41d8cd98f00b204e9800998ecf8427e",
      "entities": []
    }
  ]
}

Request size is too big

Request size is limited by approximately 32Mb.
When client sends request that exceeds this limit, the service responds with 413 code.

The typical reason for exceeding this limit is overly large image.
Taking into account additional HTTP overhead, we strongly recommend to not pass image files of size more than 16Mb.

Example response for overly big image:

Error: Request Entity Too Large

Your client issued a request that was too large.

Missing image

When client sends a request without an image, the service responds with 422 code and returns JSON object.

Example response for request with missing image:

{
  "detail": [
    {
      "loc": [
        "body",
        "image"
      ],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}