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-0.0.5.tar.gz (12.4 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-0.0.5-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jerris_client-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1b698c8e72ead9d2aa4cc03654aaa02c1d02281ecf5f15dfee1de6a3ddcc112a
MD5 f3b2c2140a2b3a31469499bcca6ec78f
BLAKE2b-256 7d91a21f32ca16deafe770e95677a16e688fa8903e63236b5ce35fbbf1efc899

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jerris_client-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4f08c1ca8a9ea6d7619bff08b0a16c27e7de7c37870eb9751c36aa59e24eb916
MD5 d94e421265ed8751b1b5193682fb7029
BLAKE2b-256 729b01638dc5fe351e419468b75141dc4394004c07c26493ec960240fd94fca1

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