imgproxykit 0.1.0__py3-none-any.whl
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.
- imgproxykit/__init__.py +2 -0
- imgproxykit/builders.py +132 -0
- imgproxykit/client.py +167 -0
- imgproxykit/internal/__init__.py +0 -0
- imgproxykit/internal/constants.py +8 -0
- imgproxykit/internal/empty.py +8 -0
- imgproxykit/internal/encoding.py +13 -0
- imgproxykit/internal/paths.py +21 -0
- imgproxykit/internal/serialization.py +34 -0
- imgproxykit/options/__init__.py +62 -0
- imgproxykit/options/auto_rotate.py +39 -0
- imgproxykit/options/background.py +46 -0
- imgproxykit/options/base.py +41 -0
- imgproxykit/options/blur.py +38 -0
- imgproxykit/options/cache_buster.py +40 -0
- imgproxykit/options/crop.py +61 -0
- imgproxykit/options/dpr.py +40 -0
- imgproxykit/options/enforce_thumbnail.py +39 -0
- imgproxykit/options/enlarge.py +38 -0
- imgproxykit/options/expires.py +38 -0
- imgproxykit/options/extend.py +50 -0
- imgproxykit/options/extend_aspect_ratio.py +50 -0
- imgproxykit/options/filename.py +41 -0
- imgproxykit/options/flip.py +44 -0
- imgproxykit/options/format_quality.py +38 -0
- imgproxykit/options/gravity.py +48 -0
- imgproxykit/options/height.py +39 -0
- imgproxykit/options/keep_copyright.py +38 -0
- imgproxykit/options/max_animation_frame_resolution.py +39 -0
- imgproxykit/options/max_animation_frames.py +39 -0
- imgproxykit/options/max_bytes.py +39 -0
- imgproxykit/options/max_result_dimension.py +39 -0
- imgproxykit/options/max_src_file_size.py +39 -0
- imgproxykit/options/max_src_resolution.py +39 -0
- imgproxykit/options/min_height.py +38 -0
- imgproxykit/options/min_width.py +38 -0
- imgproxykit/options/padding.py +50 -0
- imgproxykit/options/pixelate.py +38 -0
- imgproxykit/options/preserve_hdr.py +38 -0
- imgproxykit/options/quality.py +38 -0
- imgproxykit/options/raw.py +39 -0
- imgproxykit/options/resize.py +55 -0
- imgproxykit/options/resizing_type.py +39 -0
- imgproxykit/options/return_attachment.py +39 -0
- imgproxykit/options/rotate.py +38 -0
- imgproxykit/options/sharpen.py +38 -0
- imgproxykit/options/size.py +45 -0
- imgproxykit/options/skip_processing.py +39 -0
- imgproxykit/options/strip_color_profile.py +39 -0
- imgproxykit/options/strip_metadata.py +38 -0
- imgproxykit/options/trim.py +52 -0
- imgproxykit/options/watermark.py +60 -0
- imgproxykit/options/width.py +39 -0
- imgproxykit/options/zoom.py +45 -0
- imgproxykit/py.typed +0 -0
- imgproxykit/signing.py +114 -0
- imgproxykit/transform.py +54 -0
- imgproxykit/types.py +95 -0
- imgproxykit-0.1.0.dist-info/METADATA +150 -0
- imgproxykit-0.1.0.dist-info/RECORD +62 -0
- imgproxykit-0.1.0.dist-info/WHEEL +4 -0
- imgproxykit-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class MaxResultDimension(Option):
|
|
11
|
+
"""
|
|
12
|
+
Override output dimension limit; requires ALLOW_SECURITY_OPTIONS.
|
|
13
|
+
|
|
14
|
+
Overrides the corresponding server limit for this request. Requires
|
|
15
|
+
``IMGPROXY_ALLOW_SECURITY_OPTIONS=true`` on the imgproxy server.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
value: Maximum resulting width or height in pixels.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = MaxResultDimension(value=4096)
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
(4096,)
|
|
25
|
+
|
|
26
|
+
See `imgproxy max result dimension
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#max-result-dimension>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: int
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'mrd'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class MaxSrcFileSize(Option):
|
|
11
|
+
"""
|
|
12
|
+
Override source byte limit; requires ALLOW_SECURITY_OPTIONS.
|
|
13
|
+
|
|
14
|
+
Overrides the corresponding server limit for this request. Requires
|
|
15
|
+
``IMGPROXY_ALLOW_SECURITY_OPTIONS=true`` on the imgproxy server.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
value: Source file size limit in bytes.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = MaxSrcFileSize(value=10_000_000)
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
(10000000,)
|
|
25
|
+
|
|
26
|
+
See `imgproxy max src file size
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#max-src-file-size>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: int
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'msfs'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class MaxSrcResolution(Option):
|
|
11
|
+
"""
|
|
12
|
+
Override source megapixel limit; requires ALLOW_SECURITY_OPTIONS.
|
|
13
|
+
|
|
14
|
+
Overrides the corresponding server limit for this request. Requires
|
|
15
|
+
``IMGPROXY_ALLOW_SECURITY_OPTIONS=true`` on the imgproxy server.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
value: Source resolution limit in megapixels.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = MaxSrcResolution(value=50)
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
(50,)
|
|
25
|
+
|
|
26
|
+
See `imgproxy max src resolution
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#max-src-resolution>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: float
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'msr'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class MinHeight(Option):
|
|
11
|
+
"""
|
|
12
|
+
Set the minimum resulting height in pixels.
|
|
13
|
+
|
|
14
|
+
Combining this option with a target height can crop the result.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Minimum resulting height in pixels.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = MinHeight(value=200)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(200,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy min height
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#min-height>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: int
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'mh'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class MinWidth(Option):
|
|
11
|
+
"""
|
|
12
|
+
Set the minimum resulting width in pixels.
|
|
13
|
+
|
|
14
|
+
Combining this option with a target width can crop the result.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Minimum resulting width in pixels.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = MinWidth(value=300)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(300,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy min width
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#min-width>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: int
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'mw'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import EMPTY, Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Padding(Option):
|
|
11
|
+
"""
|
|
12
|
+
Add padding using CSS side order; specify at least one side.
|
|
13
|
+
|
|
14
|
+
Uses CSS side order and is applied after image transformations,
|
|
15
|
+
except watermarking. Padding follows DPR and uses the background color.
|
|
16
|
+
Supply at least one side; omitted arguments remain
|
|
17
|
+
:data:`~imgproxykit.types.EMPTY`.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
top: Top padding in pixels; fallback for omitted sides.
|
|
21
|
+
right: Right padding; also used for an omitted left side.
|
|
22
|
+
bottom: Bottom padding in pixels.
|
|
23
|
+
left: Left padding in pixels.
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
|
|
27
|
+
>>> option = Padding(top=10)
|
|
28
|
+
>>> option.arguments
|
|
29
|
+
(10, EMPTY, EMPTY, EMPTY)
|
|
30
|
+
>>> option = Padding(top=10, right=20, bottom=30, left=40)
|
|
31
|
+
>>> option.arguments
|
|
32
|
+
(10, 20, 30, 40)
|
|
33
|
+
|
|
34
|
+
See `imgproxy padding
|
|
35
|
+
<https://docs.imgproxy.net/usage/processing#padding>`_.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
top: int | EMPTY = EMPTY
|
|
40
|
+
right: int | EMPTY = EMPTY
|
|
41
|
+
bottom: int | EMPTY = EMPTY
|
|
42
|
+
left: int | EMPTY = EMPTY
|
|
43
|
+
|
|
44
|
+
_name: ClassVar[OptionType] = 'pd'
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
@override
|
|
48
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
49
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
50
|
+
return (self.top, self.right, self.bottom, self.left)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Pixelate(Option):
|
|
11
|
+
"""
|
|
12
|
+
Set the pixelation block size.
|
|
13
|
+
|
|
14
|
+
Larger blocks produce a coarser pixelation effect.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Individual pixel block size in pixels.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = Pixelate(value=10)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(10,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy pixelate
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#pixelate>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: int
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'pix'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class PreserveHDR(Option):
|
|
11
|
+
"""
|
|
12
|
+
Preserve high bit depth instead of converting to 8 bit.
|
|
13
|
+
|
|
14
|
+
Overrides the server high bit depth setting for this request.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Whether to retain high bit depth instead of using 8 bit.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = PreserveHDR(value=True)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(True,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy preserve hdr
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#preserve-hdr>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: bool
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'ph'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True)
|
|
10
|
+
class Quality(Option):
|
|
11
|
+
"""
|
|
12
|
+
Set output image quality.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
value: Quality percentage. Zero delegates to server quality settings.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
|
|
19
|
+
>>> option = Quality(85)
|
|
20
|
+
>>> option.arguments
|
|
21
|
+
(85,)
|
|
22
|
+
|
|
23
|
+
See `imgproxy quality
|
|
24
|
+
<https://docs.imgproxy.net/usage/processing#quality>`_.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Public API:
|
|
29
|
+
value: int
|
|
30
|
+
|
|
31
|
+
# Private API:
|
|
32
|
+
_name: ClassVar[OptionType] = 'q'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Raw(Option):
|
|
11
|
+
"""
|
|
12
|
+
Stream the unchecked source file without processing.
|
|
13
|
+
|
|
14
|
+
Streams the source without checking its type, resolution, or size.
|
|
15
|
+
The output is not transformed.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
value: Whether to stream the raw source file.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = Raw(value=True)
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
(True,)
|
|
25
|
+
|
|
26
|
+
See `imgproxy raw
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#raw>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: bool
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'raw'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import EMPTY, Argument, OptionType, ResizeType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Resize(Option):
|
|
11
|
+
"""
|
|
12
|
+
Configure image dimensions and resizing behavior.
|
|
13
|
+
|
|
14
|
+
Values left as :data:`~imgproxykit.types.EMPTY` are not supplied
|
|
15
|
+
explicitly; imgproxy resolves their defaults.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
width: Target width in pixels.
|
|
19
|
+
height: Target height in pixels.
|
|
20
|
+
mode: Resizing strategy, such as ``fit`` or ``fill``.
|
|
21
|
+
enlarge: Allow upscaling smaller source images.
|
|
22
|
+
extend: Pad images that are smaller than the target dimensions.
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
|
|
26
|
+
>>> option = Resize(width=96, height=96, mode='fill')
|
|
27
|
+
>>> option.arguments
|
|
28
|
+
('fill', 96, 96, EMPTY, EMPTY)
|
|
29
|
+
|
|
30
|
+
See `imgproxy resize
|
|
31
|
+
<https://docs.imgproxy.net/usage/processing#resize>`_.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
# Public API:
|
|
36
|
+
width: int | EMPTY = EMPTY
|
|
37
|
+
height: int | EMPTY = EMPTY
|
|
38
|
+
mode: ResizeType | EMPTY = EMPTY
|
|
39
|
+
enlarge: bool | EMPTY = EMPTY
|
|
40
|
+
extend: bool | EMPTY = EMPTY
|
|
41
|
+
|
|
42
|
+
# Private API:
|
|
43
|
+
_name: ClassVar[OptionType] = 'rs'
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
@override
|
|
47
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
48
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
49
|
+
return (
|
|
50
|
+
self.mode,
|
|
51
|
+
self.width,
|
|
52
|
+
self.height,
|
|
53
|
+
self.enlarge,
|
|
54
|
+
self.extend,
|
|
55
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType, ResizeType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class ResizingType(Option):
|
|
11
|
+
"""
|
|
12
|
+
Choose the resizing strategy.
|
|
13
|
+
|
|
14
|
+
Controls how target dimensions and the source aspect ratio interact.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Resizing strategy: ``fit``, ``fill``, ``fill-down``,
|
|
18
|
+
``force``, or ``auto``.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = ResizingType(value='fill')
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
('fill',)
|
|
25
|
+
|
|
26
|
+
See `imgproxy resizing type
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#resizing-type>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: ResizeType
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'rt'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class ReturnAttachment(Option):
|
|
11
|
+
"""
|
|
12
|
+
Request attachment disposition for downloading.
|
|
13
|
+
|
|
14
|
+
Sets attachment disposition so browsers can offer to save the image.
|
|
15
|
+
Combine with Filename to choose the downloaded filename.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
value: Whether to return an attachment disposition.
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
|
|
22
|
+
>>> option = ReturnAttachment(value=True)
|
|
23
|
+
>>> option.arguments
|
|
24
|
+
(True,)
|
|
25
|
+
|
|
26
|
+
See `imgproxy return attachment
|
|
27
|
+
<https://docs.imgproxy.net/usage/processing#return-attachment>`_.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
value: bool
|
|
32
|
+
|
|
33
|
+
_name: ClassVar[OptionType] = 'att'
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
@override
|
|
37
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
38
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
39
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Rotate(Option):
|
|
11
|
+
"""
|
|
12
|
+
Rotate clockwise by a multiple of 90 degrees.
|
|
13
|
+
|
|
14
|
+
Rotation follows EXIF orientation unless automatic rotation is disabled.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Clockwise angle in degrees; must be a multiple of 90.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = Rotate(value=90)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(90,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy rotate
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#rotate>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: int
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'rot'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Sharpen(Option):
|
|
11
|
+
"""
|
|
12
|
+
Apply sharpening with the given sigma.
|
|
13
|
+
|
|
14
|
+
The sigma controls the size of the sharpening mask.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
value: Sharpening filter sigma.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
|
|
21
|
+
>>> option = Sharpen(value=1.0)
|
|
22
|
+
>>> option.arguments
|
|
23
|
+
(1.0,)
|
|
24
|
+
|
|
25
|
+
See `imgproxy sharpen
|
|
26
|
+
<https://docs.imgproxy.net/usage/processing#sharpen>`_.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
value: float
|
|
31
|
+
|
|
32
|
+
_name: ClassVar[OptionType] = 'sh'
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@override
|
|
36
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
37
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
38
|
+
return (self.value,)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import ClassVar, final, override
|
|
3
|
+
|
|
4
|
+
from imgproxykit.options.base import Option
|
|
5
|
+
from imgproxykit.types import EMPTY, Argument, OptionType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@final
|
|
9
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
10
|
+
class Size(Option):
|
|
11
|
+
"""
|
|
12
|
+
Set target dimensions, upscaling, and canvas extension.
|
|
13
|
+
|
|
14
|
+
Values left as :data:`~imgproxykit.types.EMPTY` are not supplied
|
|
15
|
+
explicitly; imgproxy resolves their defaults.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
width: Target width in pixels.
|
|
19
|
+
height: Target height in pixels.
|
|
20
|
+
enlarge: Allow upscaling smaller source images.
|
|
21
|
+
extend: Pad images smaller than the target dimensions.
|
|
22
|
+
|
|
23
|
+
Usage:
|
|
24
|
+
|
|
25
|
+
>>> option = Size(width=300, height=200, enlarge=True)
|
|
26
|
+
>>> option.arguments
|
|
27
|
+
(300, 200, True, EMPTY)
|
|
28
|
+
|
|
29
|
+
See `imgproxy size
|
|
30
|
+
<https://docs.imgproxy.net/usage/processing#size>`_.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
width: int | EMPTY = EMPTY
|
|
35
|
+
height: int | EMPTY = EMPTY
|
|
36
|
+
enlarge: bool | EMPTY = EMPTY
|
|
37
|
+
extend: bool | EMPTY = EMPTY
|
|
38
|
+
|
|
39
|
+
_name: ClassVar[OptionType] = 's'
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
@override
|
|
43
|
+
def arguments(self) -> tuple[Argument, ...]:
|
|
44
|
+
"""Positional arguments in imgproxy protocol order."""
|
|
45
|
+
return (self.width, self.height, self.enlarge, self.extend)
|