Skip to main content

Jerris API Client for Python

Project description

Jerris API Client for Python

pipeline status

Overview

Jerris Client is a Python library designed to interact with Jerris' photo analysis API (https://jerris.ai). The service allows users to analyze images for professional photographic properties such as lighting, perspective, depth of field, and more.

The API returns a detailed description and analysis score for each photographic property provided.

  • analyze_url: Analyzes an image based on its URL.
  • analyze_binary: Analyzes an image provided in binary format.
  • analyze_file: Analyzes an image by providing the file path.
  • analyze_file_async: Asynchronously analyzes an image by providing the file path, returning a process_id.
  • analyze_binary_async: Asynchronously analyzes an image provided in binary format, returning a process_id.
  • analyze_url_async: Asynchronously analyzes an image based on its URL, returning a process_id.

Installation

You can install the library using pip:

pip install jerris-client

If the package is not available on PyPI, you can install it directly from the repository:

pip install git+http://gitlab.syrtis.be/jerris-public/python-client.git

Usage

Initializing the Client

To start using the Jerris API, initialize the client:

from jerris_jerris_client.utils.jerris_client import JerrisClient

client = JerrisClient(api_key="YOUR_API_KEY")

Analyze an Image by URL

To analyze an image via a URL, use the analyze_url method. You can provide an image URL and an optional list of parameters to specify which properties to analyze.

from jerris_jerris_client.const.parameters import JERRIS_IMAGE_PARAMETER_PERSPECTIVE_LINES,
    JERRIS_IMAGE_PARAMETER_ASPECT_RATIO

result = client.analyze_url(
    image_url="https://example.com/image.jpg",
    parameters=[
        JERRIS_IMAGE_PARAMETER_PERSPECTIVE_LINES,
        JERRIS_IMAGE_PARAMETER_ASPECT_RATIO
    ]
)

Example result:

{
  "aspect-ratio": {
    "id": 13,
    "title": "Aspect Ratio",
    "type": "string",
    "result": "Horizontal",
    "message": "The photo is wider than it is tall, indicating a horizontal aspect ratio which typically conveys a sense of space and is suitable for capturing multiple subjects."
  },
  "minimizing-distractions": {
    "id": 1,
    "title": "Minimizing Distractions",
    "type": "integer",
    "result": 0,
    "message": "No analysis"
  },
  "perspective-lines": {
    "id": 12,
    "title": "Perspective Lines",
    "type": "integer",
    "result": 0,
    "message": "No analysis"
  }
}

Analyze an Image in Binary Format

To analyze an image from binary data, use the analyze_binary method:

from jerris_jerris_client.const.parameters import JERRIS_IMAGE_PARAMETER_PERSPECTIVE_LINES,
    JERRIS_IMAGE_PARAMETER_ASPECT_RATIO

with open('path_to_image.jpg', 'rb') as image_file:
    image_binary = image_file.read()

result = client.analyze_binary(
    image_binary=image_binary,
    parameters=[
        JERRIS_IMAGE_PARAMETER_PERSPECTIVE_LINES,
        JERRIS_IMAGE_PARAMETER_ASPECT_RATIO
    ]
)

Analyze an Image by File Path

To analyze an image by providing the file path, use the analyze_file method:

result = client.analyze_file(
    file_path="path_to_image.jpg",
    parameters=[
        JERRIS_IMAGE_PARAMETER_PERSPECTIVE_LINES,
        JERRIS_IMAGE_PARAMETER_ASPECT_RATIO
    ]
)

This method automatically reads the image file and sends it for analysis, similar to analyze_binary.

Asynchronous Analysis Methods

To perform an asynchronous analysis, use the analyze_url_async, analyze_binary_async, or analyze_file_async methods. These methods return a process_id that can be used to query the status of the analysis.

# Example of initiating an asynchronous analysis
process_id = client.analyze_url_async(
    image_url="https://example.com/image.jpg"
)

# Example of retrieving the report
report = client.get_report(process_id)

# The report will return a status: 'warning' if the process is still ongoing, or the data with a status: 'success' once completed.

Running demo

pip install -r requirements-dev.txt
python3 demo/analyze.py

Restrictions

File formats

This is the mime types supported by the package, based on the file metadata (not the file extension).

HEIC, JPG, PNG, WEBP

File dimensions

  • Soft limit : 1216px x 768px, image exceeding this size will be resized before analyzing
  • Hard limit : 1800px x 1800px, an error will be thrown if image exceed this limit

License

The project follows the MIT License to allow broad usage of the library while ensuring that the service remains proprietary.

Author

This library is maintained by Jerris, a Belgian company specializing in AI-driven photography and images analysis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jerris_client-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jerris_client-1.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file jerris_client-1.0.0.tar.gz.

File metadata

  • Download URL: jerris_client-1.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for jerris_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4f768c01f1ca15e26f3d83fc307e0f8e0a4626e91aaa234013df5b2eca07cfe6
MD5 a959d8f585405711817ae623f3cdb8be
BLAKE2b-256 4303dd77064a3df29cb920aac54a021f57927ba6f0a7cd9fa6606e213ae67e61

See more details on using hashes here.

File details

Details for the file jerris_client-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: jerris_client-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for jerris_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4a5c94d2b6f2a6ef72c26934be0f21c45946181d9db740fedf43f33233a771b
MD5 f1aa207d601e06c7874769bcf2f05999
BLAKE2b-256 144a2a1070a23a608e8b4c91869f57da84553ea63f4d738b4f0ddf943138ee48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page