---
title: Image Quality API
slug: v3-gateway/image-quality-api
description: Learn how to use the Image Quality API to assess the quality of your uploaded images. This document includes guidelines, input requirements, and sample responses, along with code snippets in multiple programming languages. Discover how the API evaluates s
createdAt: 2023-06-12T16:54:53.000Z
---

## Introduction

The Image Quality API allows users to upload an image and determine its quality for further processing. The API evaluates the image based on various quality parameters and provides a score indicating its usability. This documentation provides details on how to call the API, input guidelines, sample responses, and other relevant information.

## Types of Quality Check

The product has four types of quality checks namely:

- **Sharpness check** - This feature tells if the image is sharp i.e. no blur in image is present. 0 is blur, 1 is sharp.
- **Brightness check** - This feature tells if the image is bright enough for OCR. 0 is dark, 1 is good bright.
- **Compression quality check** - This feature tells if the image is pixelated. 0 is compressed, 1 is good.
- **Text readable** - This tells whether the text present on the image is readable or not. 0 is bad, 1 is good.

## How to call the API

Before making API requests, you need to perform a login authentication and obtain an access token. The access token should be included in the authorization header of subsequent API requests. The API endpoints and environments for different operations are provided below.

## API Input Guidelines

The Image Quality API is used to detect the quality of an image and determine its usability for further processing. You can upload an image or provide a direct URL to the image.

| Endpoints                                                                       | Environment   |
| ------------------------------------------------------------------------------- | ------------- |
| https\://preproduction.signzy.tech/api/v2/patrons/&#x7B;patron-id}/imagequality | Preproduction |
| https\://signzy.tech/api/v2/patrons/&#x7B;patron-id}/imagequality               | Production    |

### Request Body Parameters

| **PARAMETER NAME**      | **Required/Optional** | **DESCRIPTION**                                                                                                                                         |
| ----------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **files**               | Required              | (array): URLs of the image files to be evaluated (array of length one).                                                                                 |
| **qualityParameter**    | Optional              | (string): Specifies the type of quality check to perform. Valid options are all, blur, brightness, compressionQuality, and textQuality. Default is all. |
| **acceptanceThreshold** |                       | (string): Acceptance threshold value between 0 and 1. Default is not set.                                                                               |



```json
{
  "essentials": {
    "files": ["...url..to..file.. (array of length one)"],
    "qualityParameter":"all | blur | brightness | compressionQuality | textQuality"
    "acceptanceThreshold":"...0-1..."
  }
}
```

### Request Header Parameters

| **Header Name** | **Required/Optional** | **DESCRIPTION**                                    |
| --------------- | --------------------- | -------------------------------------------------- |
| Authorization   | Required              | access token returned as id field of login request |
| Content-Type    | Required              | application/json                                   |

### Sample Codes

:::CodeblockTabs
```curl
curl --location 'https://signzy.tech/api/v2/patrons/...patronID.../imagequality' \
--header 'Accept-Language: en-US,en;q=0.8' \
--header 'Accept: */*' \
--header 'Authorization: <Access-Token>' \
--header 'Content-Type: application/json' \
--data '{
    "essentials": {
      "files": ["...url of the file..."],
      "qualityParameter": "all | blur | brightness | compressionQuality | textQuality"
    }
  }'
```

```nodejs
const axios = require('axios');
let data = JSON.stringify({
  "essentials": {
    "files": [
      "...url of the file..."
    ],
    "qualityParameter": "all | blur | brightness | compressionQuality | textQuality"
  }
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://signzy.tech/api/v2/patrons/...patronID.../imagequality',
  headers: { 
    'Accept-Language': 'en-US,en;q=0.8', 
    'Accept': '*/*', 
    'Authorization': '<Access-Token>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

```python
import http.client
import json

conn = http.client.HTTPSConnection("signzy.tech")
payload = json.dumps({
  "essentials": {
    "files": [
      "...url of the file..."
    ],
    "qualityParameter": "all | blur | brightness | compressionQuality | textQuality"
  }
})
headers = {
  'Accept-Language': 'en-US,en;q=0.8',
  'Accept': '*/*',
  'Authorization': '<Access-Token>',
  'Content-Type': 'application/json'
}
conn.request("POST", "/api/v2/patrons/...patronID.../imagequality", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://signzy.tech/api/v2/patrons/...patronID.../imagequality"
  method := "POST"

  payload := strings.NewReader(`{
    "essentials": {
      "files": ["...url of the file..."],
      "qualityParameter": "all | blur | brightness | compressionQuality | textQuality"
    }
  }`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Accept-Language", "en-US,en;q=0.8")
  req.Header.Add("Accept", "*/*")
  req.Header.Add("Authorization", "<Access-Token>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```
:::

***

### Sample Response

```json
{
  "essentials": {
    "files": ["{image-URL}"]
  },
  "id": "{id}",
  "patronId": "{patron-ID}",
  "result": {
    "qualityScores": {
      "sharpness": {
        "score": "0 to 1",
        "valid": "yes|no"
      },
      "brightness": {
        "score": "0 to 1",
        "valid": "yes|no"
      },
      "compressionQuality": {
        "score": "0 to 1",
        "valid": "yes|no"
      },
      "textQuality": {
        "score": "0 to 1",
        "valid": "yes|no"
      }
    },
    "extractionQuality": "veryLow|low|medium|high",
    "summary": "accept|reject",
    "score": "0 to 1",
    "msg": "done"
  }
}
```

### Response Parameter

| **Parameter** **Name** | **Description**                                                                                                                           |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **qualityScores**      |  (object): Quality scores for different parameters.                                                                                       |
| **sharpness**          | (object): Sharpness score and validity. Sharpness score ranging from 0 to 1.Validity of sharpness ("yes" or "no").                        |
| **brightness**         | Brightness score and validity.Brightness score ranging from 0 to 1.Validity of brightness ("yes" or "no").                                |
| **compressionQuality** | (object): Compression quality score and validity. Compression quality score and validity.Validity of compression quality ("yes" or "no"). |
| **textQuality**        | (object): Text quality score and validity.Text quality score ranging from 0 to 1.Validity of text quality ("yes" or "no").                |
| **summary**            | (string): Summary of the image quality ("accept" or "reject").                                                                            |
| **score**              | (string): Overall quality score ranging from 0 to 1.                                                                                      |
| **msg**                | (string): Status message indicating the completion of the API call.                                                                       |

**Note**: Please note that the maximum image size supported is 2MB.

***

### Sample Error

:::CodeblockTabs
```json
{
    "error": {
        "name": "error"
        "status": "...status code...",
        "msg": "...reason...",
        "responseCode": "fail"
    }
}
```

400

```json
{
    "error": {
        "name": "Invalid Request JSON Syntax",
        "status": "400",
        "msg": "Expecting property name enclosed in double quotes: line 3 column 3 (char 155)",
        "responseCode": "fail"
    }
}
```

401

```json
{
    "message": "No API key found in request"
}
```

422

```json
{
    "error": {
        "status": "422",
        "msg": "Invalid request parameters: The image has expired",
        "responseCode": "fail"
    }
}
```
:::

### Status Codes

| Status Code | Description                    |
| ----------- | ------------------------------ |
| 200         | OK                             |
| 400         | Bad Request                    |
| 401         | Authorization token is invalid |
| 422         | Unprocessable Entity           |

***

:::hint{type="info"}
### Getting help

Please feel free to contact us if you have any questions, require clarification, or have ideas for how to make the documents or any of our services better.


You can reach out to us at [help@signzy.com](#).
:::

