Skip to main content

optivor (Python SDK)

Official Python SDK for Optivor image optimization engine (Django, FastAPI, Flask).

PyPI version License GitHub stars

If you find Optivor useful, please consider giving us a Star on GitHub!

The optivor Python package provides helper methods for building signed and dynamic image transformation URLs.


Installation

pip install optivor

Basic Usage

from optivor import OptivorClient

optivor = OptivorClient(
    base_url="https://optivor.example.com",
    default_bucket="my-bucket"
)

```python
# Preset-based image optimization (Recommended)
preset_url = optivor.build_preset_url("avatar", "users/john.jpg")
# => https://optivor.example.com/preset/avatar/my-bucket/users/john.jpg

# Generate WebP image URL
url = optivor.build_url(
    "photos/landscape.jpg",
    width=800,
    height=600,
    fit="cover",
    format="webp"
)
# => https://optivor.example.com/image/my-bucket/photos/landscape.jpg?w=800&h=600&fit=cover&format=webp

Advanced Options

url = optivor.build_url(
    "users/avatar.jpg",
    width=400,
    height=400,
    fit="focal",
    focal=(0.3, 0.7),
    format="avif",
    overlay="logo.png",
    gravity="bottom_right",
    opacity=60,
    blur=5.0,
    grayscale=True,
    pixelate=4
)

Watermark Security & Tamper Protection

To prevent end-users from stripping overlay= or watermark query parameters from public URLs:

  1. HMAC URL Signing: Generate signed URLs using security_key. The HMAC-SHA256 signature locks both the path and query parameters (overlay=). Modifying or removing the overlay parameter invalidates the signature, returning 403 Forbidden.
  2. Server-Side Presets (build_preset_url): Use optivor.build_preset_url('watermarked_thumb', key) to process images using server-side presets defined in optivor.yaml. The overlay rule stays on the server, leaving no parameters for users to tamper with.

Django Integration Example

# settings.py
OPTIVOR_URL = "https://optivor.example.com"
OPTIVOR_BUCKET = "prod-images"

# templatetags/optivor_tags.py
from django import template
from optivor import OptivorClient
from django.conf import settings

register = template.Library()
optivor = OptivorClient(settings.OPTIVOR_URL, settings.OPTIVOR_BUCKET)

@register.simple_tag
def optivor_url(key, **kwargs):
    return optivor.build_url(key, **kwargs)

License

Apache-2.0 © Optivor Team

Download files

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

Source Distribution

optivor-1.2.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

optivor-1.2.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file optivor-1.2.3.tar.gz.

File metadata

  • Download URL: optivor-1.2.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for optivor-1.2.3.tar.gz
Algorithm Hash digest
SHA256 bc02ee1cd85aed63260765b45f36ed339c94972976a57a80bd4d2d577756ff4c
MD5 498a44a85fc2192d8ac95ea403b342ba
BLAKE2b-256 c6e7f5553caffbf1fcdd1ce36e2201dfd48faac5812899895c6a6eeb76252d8b

See more details on using hashes here.

File details

Details for the file optivor-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: optivor-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for optivor-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d48ee2a901924a42ff481958f36ba77dcbddfef33e43d2e6b435e93cf68448b0
MD5 66e77dbb2f2d267b44e6f8221350b9a0
BLAKE2b-256 a3e668b665f4bcd4d5374d22664e0ae35641d06433b268aec32e091a88f92c74

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 files

1.2.1

2 files

1.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page