# Image requirements

The API expects the input image to have certain requirements in order to accurately perform facial liveness checks.

### Best practices&#x20;

* Supported image formats: png, jpg, jpeg.
* Image size should not exceed: 10mb
* Image should be clicked in a well-lit room, with the face shown clearly to the camera. Extreme darkness/brightness on the face might increase the BPCER.
* The Face should be straight and not tilted.&#x20;
* Minimum Size of detected face should be 224X224 pixels. (APCER will be affected for very small face bboxes)
* The padding between the face box and the image's borders should be at least 15 pixels.&#x20;
* Distance between eyes should be ateast 100 pixels.
* Motion Blur might increase BPCER.
* Any occlusions on parts of face like Glasses, Masks should be removed while performing Liveness Check.
* The detected Face should occupy atleast 20% of the total image area.
* Image should be clicked as a selfie (portrait mode only).&#x20;
* No image compression is highly recommended.

### Compressing Images for high performance - python

Use the following snippet to reduce the size of the images before sending it to the spoofsense-api.

```python
from PIL import Image

def compress_image(image_path, output_path, quality):
    # Open the image file.
    with Image.open(image_path) as img:
        # Save the image again with reduced quality.
        img.save(output_path, "JPEG", quality=quality)

# Path of the image to be compressed.
image_path = "path/to/your/image.jpg"

# Path where the compressed image will be saved.
output_path = "path/to/your/compressed/image.jpg"

# Quality parameter. Lower value will reduce the size more, but may decrease the quality.
# In many cases, values around 80 to 90 still provide good quality images.
quality = 90

compress_image(image_path, output_path, quality)

```

### <br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spoofsense.gitbook.io/spoofsense-triton-documentation/image-requirements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
