optivor 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
optivor-1.2.0/PKG-INFO ADDED
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: optivor
3
+ Version: 1.2.0
4
+ Summary: Official Python SDK for Optivor image optimization engine (Django / FastAPI support)
5
+ Author: Optivor Team
6
+ License: Apache-2.0
7
+ Description-Content-Type: text/markdown
8
+
9
+ # `optivor` (Python SDK)
10
+
11
+ > Official Python SDK for [Optivor](https://github.com/optivor/optivor) image optimization engine (Django, FastAPI, Flask).
12
+
13
+ [![PyPI version](https://img.shields.io/pypi/v/optivor.svg)](https://pypi.org/project/optivor/)
14
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
15
+
16
+ The `optivor` Python package provides helper methods for building signed and dynamic image transformation URLs.
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install optivor
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Basic Usage
29
+
30
+ ```python
31
+ from optivor import OptivorClient
32
+
33
+ optivor = OptivorClient(
34
+ base_url="https://optivor.example.com",
35
+ default_bucket="my-bucket"
36
+ )
37
+
38
+ # Generate WebP image URL
39
+ url = optivor.build_url(
40
+ "photos/landscape.jpg",
41
+ width=800,
42
+ height=600,
43
+ fit="cover",
44
+ format="webp"
45
+ )
46
+ # => https://optivor.example.com/image/my-bucket/photos/landscape.jpg?w=800&h=600&fit=cover&format=webp
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Advanced Options
52
+
53
+ ```python
54
+ url = optivor.build_url(
55
+ "users/avatar.jpg",
56
+ width=400,
57
+ height=400,
58
+ fit="focal",
59
+ focal=(0.3, 0.7),
60
+ format="avif",
61
+ overlay="logo.png",
62
+ gravity="bottom_right",
63
+ opacity=60,
64
+ blur=5.0,
65
+ grayscale=True,
66
+ pixelate=4
67
+ )
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Django Integration Example
73
+
74
+ ```python
75
+ # settings.py
76
+ OPTIVOR_URL = "https://optivor.example.com"
77
+ OPTIVOR_BUCKET = "prod-images"
78
+
79
+ # templatetags/optivor_tags.py
80
+ from django import template
81
+ from optivor import OptivorClient
82
+ from django.conf import settings
83
+
84
+ register = template.Library()
85
+ optivor = OptivorClient(settings.OPTIVOR_URL, settings.OPTIVOR_BUCKET)
86
+
87
+ @register.simple_tag
88
+ def optivor_url(key, **kwargs):
89
+ return optivor.build_url(key, **kwargs)
90
+ ```
91
+
92
+ ---
93
+
94
+ ## License
95
+
96
+ Apache-2.0 © Optivor Team
@@ -0,0 +1,88 @@
1
+ # `optivor` (Python SDK)
2
+
3
+ > Official Python SDK for [Optivor](https://github.com/optivor/optivor) image optimization engine (Django, FastAPI, Flask).
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/optivor.svg)](https://pypi.org/project/optivor/)
6
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
7
+
8
+ The `optivor` Python package provides helper methods for building signed and dynamic image transformation URLs.
9
+
10
+ ---
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install optivor
16
+ ```
17
+
18
+ ---
19
+
20
+ ## Basic Usage
21
+
22
+ ```python
23
+ from optivor import OptivorClient
24
+
25
+ optivor = OptivorClient(
26
+ base_url="https://optivor.example.com",
27
+ default_bucket="my-bucket"
28
+ )
29
+
30
+ # Generate WebP image URL
31
+ url = optivor.build_url(
32
+ "photos/landscape.jpg",
33
+ width=800,
34
+ height=600,
35
+ fit="cover",
36
+ format="webp"
37
+ )
38
+ # => https://optivor.example.com/image/my-bucket/photos/landscape.jpg?w=800&h=600&fit=cover&format=webp
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Advanced Options
44
+
45
+ ```python
46
+ url = optivor.build_url(
47
+ "users/avatar.jpg",
48
+ width=400,
49
+ height=400,
50
+ fit="focal",
51
+ focal=(0.3, 0.7),
52
+ format="avif",
53
+ overlay="logo.png",
54
+ gravity="bottom_right",
55
+ opacity=60,
56
+ blur=5.0,
57
+ grayscale=True,
58
+ pixelate=4
59
+ )
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Django Integration Example
65
+
66
+ ```python
67
+ # settings.py
68
+ OPTIVOR_URL = "https://optivor.example.com"
69
+ OPTIVOR_BUCKET = "prod-images"
70
+
71
+ # templatetags/optivor_tags.py
72
+ from django import template
73
+ from optivor import OptivorClient
74
+ from django.conf import settings
75
+
76
+ register = template.Library()
77
+ optivor = OptivorClient(settings.OPTIVOR_URL, settings.OPTIVOR_BUCKET)
78
+
79
+ @register.simple_tag
80
+ def optivor_url(key, **kwargs):
81
+ return optivor.build_url(key, **kwargs)
82
+ ```
83
+
84
+ ---
85
+
86
+ ## License
87
+
88
+ Apache-2.0 © Optivor Team
@@ -0,0 +1,41 @@
1
+ from urllib.parse import urlencode, rstrip
2
+
3
+ class OptivorClient:
4
+ def __init__(self, base_url: str = "http://localhost:8080", default_bucket: str = ""):
5
+ self.base_url = base_url.rstrip("/")
6
+ self.default_bucket = default_bucket
7
+
8
+ def build_url(self, key: str, **params) -> str:
9
+ clean_key = key.lstrip("/")
10
+ if self.default_bucket and "/" not in clean_key:
11
+ full_path = f"{self.default_bucket}/{clean_key}"
12
+ else:
13
+ full_path = clean_key
14
+
15
+ query = {}
16
+ if "width" in params or "w" in params:
17
+ query["w"] = params.get("width") or params.get("w")
18
+ if "height" in params or "h" in params:
19
+ query["h"] = params.get("height") or params.get("h")
20
+ if "fit" in params:
21
+ query["fit"] = params["fit"]
22
+ if "format" in params:
23
+ query["format"] = params["format"]
24
+ if "focal" in params:
25
+ focal = params["focal"]
26
+ query["focal"] = ",".join(map(str, focal)) if isinstance(focal, (list, tuple)) else str(focal)
27
+ if "overlay" in params:
28
+ query["overlay"] = params["overlay"]
29
+ if "gravity" in params:
30
+ query["gravity"] = params["gravity"]
31
+ if "opacity" in params:
32
+ query["opacity"] = params["opacity"]
33
+ if "blur" in params:
34
+ query["blur"] = params["blur"]
35
+ if params.get("grayscale"):
36
+ query["grayscale"] = "true"
37
+ if "pixelate" in params:
38
+ query["pixelate"] = params["pixelate"]
39
+
40
+ q_str = urlencode(query)
41
+ return f"{self.base_url}/image/{full_path}{'?' + q_str if q_str else ''}"
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: optivor
3
+ Version: 1.2.0
4
+ Summary: Official Python SDK for Optivor image optimization engine (Django / FastAPI support)
5
+ Author: Optivor Team
6
+ License: Apache-2.0
7
+ Description-Content-Type: text/markdown
8
+
9
+ # `optivor` (Python SDK)
10
+
11
+ > Official Python SDK for [Optivor](https://github.com/optivor/optivor) image optimization engine (Django, FastAPI, Flask).
12
+
13
+ [![PyPI version](https://img.shields.io/pypi/v/optivor.svg)](https://pypi.org/project/optivor/)
14
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
15
+
16
+ The `optivor` Python package provides helper methods for building signed and dynamic image transformation URLs.
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install optivor
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Basic Usage
29
+
30
+ ```python
31
+ from optivor import OptivorClient
32
+
33
+ optivor = OptivorClient(
34
+ base_url="https://optivor.example.com",
35
+ default_bucket="my-bucket"
36
+ )
37
+
38
+ # Generate WebP image URL
39
+ url = optivor.build_url(
40
+ "photos/landscape.jpg",
41
+ width=800,
42
+ height=600,
43
+ fit="cover",
44
+ format="webp"
45
+ )
46
+ # => https://optivor.example.com/image/my-bucket/photos/landscape.jpg?w=800&h=600&fit=cover&format=webp
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Advanced Options
52
+
53
+ ```python
54
+ url = optivor.build_url(
55
+ "users/avatar.jpg",
56
+ width=400,
57
+ height=400,
58
+ fit="focal",
59
+ focal=(0.3, 0.7),
60
+ format="avif",
61
+ overlay="logo.png",
62
+ gravity="bottom_right",
63
+ opacity=60,
64
+ blur=5.0,
65
+ grayscale=True,
66
+ pixelate=4
67
+ )
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Django Integration Example
73
+
74
+ ```python
75
+ # settings.py
76
+ OPTIVOR_URL = "https://optivor.example.com"
77
+ OPTIVOR_BUCKET = "prod-images"
78
+
79
+ # templatetags/optivor_tags.py
80
+ from django import template
81
+ from optivor import OptivorClient
82
+ from django.conf import settings
83
+
84
+ register = template.Library()
85
+ optivor = OptivorClient(settings.OPTIVOR_URL, settings.OPTIVOR_BUCKET)
86
+
87
+ @register.simple_tag
88
+ def optivor_url(key, **kwargs):
89
+ return optivor.build_url(key, **kwargs)
90
+ ```
91
+
92
+ ---
93
+
94
+ ## License
95
+
96
+ Apache-2.0 © Optivor Team
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ optivor/__init__.py
4
+ optivor.egg-info/PKG-INFO
5
+ optivor.egg-info/SOURCES.txt
6
+ optivor.egg-info/dependency_links.txt
7
+ optivor.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ optivor
@@ -0,0 +1,12 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "optivor"
7
+ version = "1.2.0"
8
+ description = "Official Python SDK for Optivor image optimization engine (Django / FastAPI support)"
9
+ readme = "README.md"
10
+ authors = [{ name = "Optivor Team" }]
11
+ license = { text = "Apache-2.0" }
12
+ dependencies = []
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+