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.
Files changed (62) hide show
  1. imgproxykit/__init__.py +2 -0
  2. imgproxykit/builders.py +132 -0
  3. imgproxykit/client.py +167 -0
  4. imgproxykit/internal/__init__.py +0 -0
  5. imgproxykit/internal/constants.py +8 -0
  6. imgproxykit/internal/empty.py +8 -0
  7. imgproxykit/internal/encoding.py +13 -0
  8. imgproxykit/internal/paths.py +21 -0
  9. imgproxykit/internal/serialization.py +34 -0
  10. imgproxykit/options/__init__.py +62 -0
  11. imgproxykit/options/auto_rotate.py +39 -0
  12. imgproxykit/options/background.py +46 -0
  13. imgproxykit/options/base.py +41 -0
  14. imgproxykit/options/blur.py +38 -0
  15. imgproxykit/options/cache_buster.py +40 -0
  16. imgproxykit/options/crop.py +61 -0
  17. imgproxykit/options/dpr.py +40 -0
  18. imgproxykit/options/enforce_thumbnail.py +39 -0
  19. imgproxykit/options/enlarge.py +38 -0
  20. imgproxykit/options/expires.py +38 -0
  21. imgproxykit/options/extend.py +50 -0
  22. imgproxykit/options/extend_aspect_ratio.py +50 -0
  23. imgproxykit/options/filename.py +41 -0
  24. imgproxykit/options/flip.py +44 -0
  25. imgproxykit/options/format_quality.py +38 -0
  26. imgproxykit/options/gravity.py +48 -0
  27. imgproxykit/options/height.py +39 -0
  28. imgproxykit/options/keep_copyright.py +38 -0
  29. imgproxykit/options/max_animation_frame_resolution.py +39 -0
  30. imgproxykit/options/max_animation_frames.py +39 -0
  31. imgproxykit/options/max_bytes.py +39 -0
  32. imgproxykit/options/max_result_dimension.py +39 -0
  33. imgproxykit/options/max_src_file_size.py +39 -0
  34. imgproxykit/options/max_src_resolution.py +39 -0
  35. imgproxykit/options/min_height.py +38 -0
  36. imgproxykit/options/min_width.py +38 -0
  37. imgproxykit/options/padding.py +50 -0
  38. imgproxykit/options/pixelate.py +38 -0
  39. imgproxykit/options/preserve_hdr.py +38 -0
  40. imgproxykit/options/quality.py +38 -0
  41. imgproxykit/options/raw.py +39 -0
  42. imgproxykit/options/resize.py +55 -0
  43. imgproxykit/options/resizing_type.py +39 -0
  44. imgproxykit/options/return_attachment.py +39 -0
  45. imgproxykit/options/rotate.py +38 -0
  46. imgproxykit/options/sharpen.py +38 -0
  47. imgproxykit/options/size.py +45 -0
  48. imgproxykit/options/skip_processing.py +39 -0
  49. imgproxykit/options/strip_color_profile.py +39 -0
  50. imgproxykit/options/strip_metadata.py +38 -0
  51. imgproxykit/options/trim.py +52 -0
  52. imgproxykit/options/watermark.py +60 -0
  53. imgproxykit/options/width.py +39 -0
  54. imgproxykit/options/zoom.py +45 -0
  55. imgproxykit/py.typed +0 -0
  56. imgproxykit/signing.py +114 -0
  57. imgproxykit/transform.py +54 -0
  58. imgproxykit/types.py +95 -0
  59. imgproxykit-0.1.0.dist-info/METADATA +150 -0
  60. imgproxykit-0.1.0.dist-info/RECORD +62 -0
  61. imgproxykit-0.1.0.dist-info/WHEEL +4 -0
  62. imgproxykit-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,61 @@
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, Position
6
+
7
+
8
+ @final
9
+ @dataclass(frozen=True, slots=True, kw_only=True)
10
+ class Crop(Option):
11
+ """
12
+ Crop before resizing; dimensions below one are relative.
13
+
14
+ Defines the source area to process before resizing. Omitted gravity
15
+ uses the request gravity; omitted arguments remain
16
+ :data:`~imgproxykit.types.EMPTY`.
17
+
18
+ Attributes:
19
+ width: Crop width: pixels at or above one, relative below one.
20
+ Zero uses the full source width.
21
+ height: Crop height: pixels at or above one, relative below one.
22
+ Zero uses the full source height.
23
+ gravity: Crop anchor, such as ``ce`` or ``fp``.
24
+ offset_x: Horizontal gravity offset or focus X coordinate.
25
+ offset_y: Vertical gravity offset or focus Y coordinate.
26
+
27
+ Usage:
28
+
29
+ >>> option = Crop(width=300, height=200, gravity='ce')
30
+ >>> option.arguments
31
+ (300, 200, 'ce', EMPTY, EMPTY)
32
+ >>> option = Crop(
33
+ ... width=0.5, height=0.5, gravity='fp', offset_x=0.5, offset_y=0.5
34
+ ... )
35
+ >>> option.arguments
36
+ (0.5, 0.5, 'fp', 0.5, 0.5)
37
+
38
+ See `imgproxy crop
39
+ <https://docs.imgproxy.net/usage/processing#crop>`_.
40
+
41
+ """
42
+
43
+ width: float | EMPTY = EMPTY
44
+ height: float | EMPTY = EMPTY
45
+ gravity: Position | EMPTY = EMPTY
46
+ offset_x: float | EMPTY = EMPTY
47
+ offset_y: float | EMPTY = EMPTY
48
+
49
+ _name: ClassVar[OptionType] = 'c'
50
+
51
+ @property
52
+ @override
53
+ def arguments(self) -> tuple[Argument, ...]:
54
+ """Positional arguments in imgproxy protocol order."""
55
+ return (
56
+ self.width,
57
+ self.height,
58
+ self.gravity,
59
+ self.offset_x,
60
+ self.offset_y,
61
+ )
@@ -0,0 +1,40 @@
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 DPR(Option):
11
+ """
12
+ Scale an image for high pixel density displays.
13
+
14
+ The factor also scales gravity offsets, watermark offsets, and padding.
15
+
16
+ Attributes:
17
+ value: Positive pixel density multiplier.
18
+
19
+ Usage:
20
+
21
+ >>> option = DPR(2)
22
+ >>> option.arguments
23
+ (2,)
24
+
25
+ See `imgproxy DPR
26
+ <https://docs.imgproxy.net/usage/processing#dpr>`_.
27
+
28
+ """
29
+
30
+ # Public API:
31
+ value: float
32
+
33
+ # Private API:
34
+ _name: ClassVar[OptionType] = 'dpr'
35
+
36
+ @property
37
+ @override
38
+ def arguments(self) -> tuple[Argument, ...]:
39
+ """Positional arguments in imgproxy protocol order."""
40
+ 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 EnforceThumbnail(Option):
11
+ """
12
+ Use an embedded HEIC or AVIF thumbnail when available.
13
+
14
+ Uses the embedded thumbnail instead of the main source image
15
+ when available. Supported for HEIC and AVIF sources.
16
+
17
+ Attributes:
18
+ value: Whether to prefer an embedded thumbnail.
19
+
20
+ Usage:
21
+
22
+ >>> option = EnforceThumbnail(value=True)
23
+ >>> option.arguments
24
+ (True,)
25
+
26
+ See `imgproxy enforce thumbnail
27
+ <https://docs.imgproxy.net/usage/processing#enforce-thumbnail>`_.
28
+
29
+ """
30
+
31
+ value: bool
32
+
33
+ _name: ClassVar[OptionType] = 'eth'
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 Enlarge(Option):
11
+ """
12
+ Allow upscaling smaller source images.
13
+
14
+ Allows imgproxy to upscale sources smaller than the target dimensions.
15
+
16
+ Attributes:
17
+ value: Whether smaller source images may be enlarged.
18
+
19
+ Usage:
20
+
21
+ >>> option = Enlarge(value=True)
22
+ >>> option.arguments
23
+ (True,)
24
+
25
+ See `imgproxy enlarge
26
+ <https://docs.imgproxy.net/usage/processing#enlarge>`_.
27
+
28
+ """
29
+
30
+ value: bool
31
+
32
+ _name: ClassVar[OptionType] = 'el'
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 Expires(Option):
11
+ """
12
+ Reject the URL after the given Unix timestamp.
13
+
14
+ imgproxy returns HTTP 404 after the supplied timestamp has expired.
15
+
16
+ Attributes:
17
+ value: Expiration time as a Unix timestamp in seconds.
18
+
19
+ Usage:
20
+
21
+ >>> option = Expires(value=1_900_000_000)
22
+ >>> option.arguments
23
+ (1900000000,)
24
+
25
+ See `imgproxy expires
26
+ <https://docs.imgproxy.net/usage/processing#expires>`_.
27
+
28
+ """
29
+
30
+ value: int
31
+
32
+ _name: ClassVar[OptionType] = 'exp'
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, Position
6
+
7
+
8
+ @final
9
+ @dataclass(frozen=True, slots=True, kw_only=True)
10
+ class Extend(Option):
11
+ """
12
+ Extend the canvas to the target dimensions.
13
+
14
+ Omitted settings remain :data:`~imgproxykit.types.EMPTY`. The default
15
+ anchor is center without offsets; smart gravity is unsupported.
16
+
17
+ Attributes:
18
+ value: Whether canvas extension is enabled.
19
+ gravity: Canvas anchor, such as ``ce``, ``so``, or ``fp``.
20
+ offset_x: Horizontal gravity offset or focus X coordinate.
21
+ offset_y: Vertical gravity offset or focus Y coordinate.
22
+
23
+ Usage:
24
+
25
+ >>> option = Extend(value=True, gravity='so')
26
+ >>> option.arguments
27
+ (True, 'so', EMPTY, EMPTY)
28
+
29
+ See `imgproxy extend
30
+ <https://docs.imgproxy.net/usage/processing#extend>`_.
31
+
32
+ """
33
+
34
+ value: bool
35
+ gravity: Position | EMPTY = EMPTY
36
+ offset_x: float | EMPTY = EMPTY
37
+ offset_y: float | EMPTY = EMPTY
38
+
39
+ _name: ClassVar[OptionType] = 'ex'
40
+
41
+ @property
42
+ @override
43
+ def arguments(self) -> tuple[Argument, ...]:
44
+ """Positional arguments in imgproxy protocol order."""
45
+ return (
46
+ self.value,
47
+ self.gravity,
48
+ self.offset_x,
49
+ self.offset_y,
50
+ )
@@ -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, Position
6
+
7
+
8
+ @final
9
+ @dataclass(frozen=True, slots=True, kw_only=True)
10
+ class ExtendAspectRatio(Option):
11
+ """
12
+ Extend the canvas to the requested aspect ratio.
13
+
14
+ Omitted settings remain :data:`~imgproxykit.types.EMPTY`. The default
15
+ anchor is center without offsets; smart gravity is unsupported.
16
+
17
+ Attributes:
18
+ value: Whether canvas extension is enabled.
19
+ gravity: Canvas anchor, such as ``ce``, ``so``, or ``fp``.
20
+ offset_x: Horizontal gravity offset or focus X coordinate.
21
+ offset_y: Vertical gravity offset or focus Y coordinate.
22
+
23
+ Usage:
24
+
25
+ >>> option = ExtendAspectRatio(value=True, gravity='so')
26
+ >>> option.arguments
27
+ (True, 'so', EMPTY, EMPTY)
28
+
29
+ See `imgproxy extend aspect ratio
30
+ <https://docs.imgproxy.net/usage/processing#extend-aspect-ratio>`_.
31
+
32
+ """
33
+
34
+ value: bool
35
+ gravity: Position | EMPTY = EMPTY
36
+ offset_x: float | EMPTY = EMPTY
37
+ offset_y: float | EMPTY = EMPTY
38
+
39
+ _name: ClassVar[OptionType] = 'exar'
40
+
41
+ @property
42
+ @override
43
+ def arguments(self) -> tuple[Argument, ...]:
44
+ """Positional arguments in imgproxy protocol order."""
45
+ return (
46
+ self.value,
47
+ self.gravity,
48
+ self.offset_x,
49
+ self.offset_y,
50
+ )
@@ -0,0 +1,41 @@
1
+ from dataclasses import dataclass
2
+ from typing import ClassVar, final, override
3
+
4
+ from imgproxykit.internal.encoding import encode_base64
5
+ from imgproxykit.options.base import Option
6
+ from imgproxykit.types import Argument, OptionType
7
+
8
+
9
+ @final
10
+ @dataclass(frozen=True, slots=True, kw_only=True)
11
+ class Filename(Option):
12
+ """
13
+ Set the response filename using URL-safe Base64 encoding.
14
+
15
+ Sets the filename in the Content-Disposition response header.
16
+ The name is encoded as URL-safe Base64 automatically. Combine with
17
+ ReturnAttachment to request downloading in the browser.
18
+
19
+ Attributes:
20
+ value: Response filename, supplied as unencoded text.
21
+
22
+ Usage:
23
+
24
+ >>> option = Filename(value='product photo.jpg')
25
+ >>> option.arguments
26
+ ('cHJvZHVjdCBwaG90by5qcGc', True)
27
+
28
+ See `imgproxy filename
29
+ <https://docs.imgproxy.net/usage/processing#filename>`_.
30
+
31
+ """
32
+
33
+ value: str
34
+
35
+ _name: ClassVar[OptionType] = 'fn'
36
+
37
+ @property
38
+ @override
39
+ def arguments(self) -> tuple[Argument, ...]:
40
+ """Positional arguments in imgproxy protocol order."""
41
+ return (encode_base64(self.value), True)
@@ -0,0 +1,44 @@
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 Flip(Option):
11
+ """
12
+ Flip the image horizontally and/or vertically.
13
+
14
+ Omitted axes remain :data:`~imgproxykit.types.EMPTY` and use
15
+ imgproxy defaults.
16
+
17
+ Attributes:
18
+ horizontal: Whether to mirror the image horizontally.
19
+ vertical: Whether to mirror the image vertically.
20
+
21
+ Usage:
22
+
23
+ >>> option = Flip(horizontal=True)
24
+ >>> option.arguments
25
+ (True, EMPTY)
26
+ >>> option = Flip(horizontal=True, vertical=True)
27
+ >>> option.arguments
28
+ (True, True)
29
+
30
+ See `imgproxy flip
31
+ <https://docs.imgproxy.net/usage/processing#flip>`_.
32
+
33
+ """
34
+
35
+ horizontal: bool | EMPTY = EMPTY
36
+ vertical: bool | EMPTY = EMPTY
37
+
38
+ _name: ClassVar[OptionType] = 'fl'
39
+
40
+ @property
41
+ @override
42
+ def arguments(self) -> tuple[Argument, ...]:
43
+ """Positional arguments in imgproxy protocol order."""
44
+ return (self.horizontal, self.vertical)
@@ -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, FormatType, OptionType
6
+
7
+
8
+ @final
9
+ @dataclass(frozen=True, slots=True, kw_only=True)
10
+ class FormatQuality(Option):
11
+ """
12
+ Set quality for each supplied output format.
13
+
14
+ Adds or overrides server quality settings for the listed formats.
15
+
16
+ Attributes:
17
+ qualities: Ordered pairs of output format and quality percentage.
18
+
19
+ Usage:
20
+
21
+ >>> option = FormatQuality(qualities=(('jpg', 85), ('webp', 80)))
22
+ >>> option.arguments
23
+ ('jpg', 85, 'webp', 80)
24
+
25
+ See `imgproxy format quality
26
+ <https://docs.imgproxy.net/usage/processing#format-quality>`_.
27
+
28
+ """
29
+
30
+ qualities: tuple[tuple[FormatType, int], ...]
31
+
32
+ _name: ClassVar[OptionType] = 'fq'
33
+
34
+ @property
35
+ @override
36
+ def arguments(self) -> tuple[Argument, ...]:
37
+ """Positional arguments in imgproxy protocol order."""
38
+ return tuple(argument for pair in self.qualities for argument in pair)
@@ -0,0 +1,48 @@
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, Position
6
+
7
+
8
+ @final
9
+ @dataclass(frozen=True, slots=True, kw_only=True)
10
+ class Gravity(Option):
11
+ """
12
+ Choose the image area retained when cropping.
13
+
14
+ Omitted offsets remain :data:`~imgproxykit.types.EMPTY`.
15
+
16
+ Attributes:
17
+ position: Anchor such as ``ce`` (center), ``sm`` (smart),
18
+ or ``fp`` (focus point).
19
+ offset_x: Horizontal offset; with ``fp``, the focus X coordinate.
20
+ offset_y: Vertical offset; with ``fp``, the focus Y coordinate.
21
+
22
+ Usage:
23
+
24
+ >>> option = Gravity(position='ce')
25
+ >>> option.arguments
26
+ ('ce', EMPTY, EMPTY)
27
+ >>> option = Gravity(position='fp', offset_x=0.25, offset_y=0.5)
28
+ >>> option.arguments
29
+ ('fp', 0.25, 0.5)
30
+
31
+ See `imgproxy gravity
32
+ <https://docs.imgproxy.net/usage/processing#gravity>`_.
33
+
34
+ """
35
+
36
+ # Public API:
37
+ position: Position
38
+ offset_x: float | EMPTY = EMPTY
39
+ offset_y: float | EMPTY = EMPTY
40
+
41
+ # Private API:
42
+ _name: ClassVar[OptionType] = 'g'
43
+
44
+ @property
45
+ @override
46
+ def arguments(self) -> tuple[Argument, ...]:
47
+ """Positional arguments in imgproxy protocol order."""
48
+ return (self.position, self.offset_x, self.offset_y)
@@ -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 Height(Option):
11
+ """
12
+ Set the target height in pixels.
13
+
14
+ Zero lets imgproxy calculate height from width and aspect ratio.
15
+ With force resizing, zero preserves the source height.
16
+
17
+ Attributes:
18
+ value: Target height in pixels.
19
+
20
+ Usage:
21
+
22
+ >>> option = Height(value=200)
23
+ >>> option.arguments
24
+ (200,)
25
+
26
+ See `imgproxy height
27
+ <https://docs.imgproxy.net/usage/processing#height>`_.
28
+
29
+ """
30
+
31
+ value: int
32
+
33
+ _name: ClassVar[OptionType] = 'h'
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 KeepCopyright(Option):
11
+ """
12
+ Preserve copyright information when stripping metadata.
13
+
14
+ Applies when metadata is being stripped from the output image.
15
+
16
+ Attributes:
17
+ value: Whether to retain copyright metadata.
18
+
19
+ Usage:
20
+
21
+ >>> option = KeepCopyright(value=True)
22
+ >>> option.arguments
23
+ (True,)
24
+
25
+ See `imgproxy keep copyright
26
+ <https://docs.imgproxy.net/usage/processing#keep-copyright>`_.
27
+
28
+ """
29
+
30
+ value: bool
31
+
32
+ _name: ClassVar[OptionType] = 'kcr'
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 MaxAnimationFrameResolution(Option):
11
+ """
12
+ Override frame 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: Animation frame resolution limit in megapixels.
19
+
20
+ Usage:
21
+
22
+ >>> option = MaxAnimationFrameResolution(value=20)
23
+ >>> option.arguments
24
+ (20,)
25
+
26
+ See `imgproxy max animation frame resolution
27
+ <https://docs.imgproxy.net/usage/processing#max-animation-frame-resolution>`_.
28
+
29
+ """
30
+
31
+ value: float
32
+
33
+ _name: ClassVar[OptionType] = 'mafr'
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 MaxAnimationFrames(Option):
11
+ """
12
+ Override animation frame 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 number of animation frames.
19
+
20
+ Usage:
21
+
22
+ >>> option = MaxAnimationFrames(value=100)
23
+ >>> option.arguments
24
+ (100,)
25
+
26
+ See `imgproxy max animation frames
27
+ <https://docs.imgproxy.net/usage/processing#max-animation-frames>`_.
28
+
29
+ """
30
+
31
+ value: int
32
+
33
+ _name: ClassVar[OptionType] = 'maf'
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 MaxBytes(Option):
11
+ """
12
+ Reduce output quality to meet the requested byte limit.
13
+
14
+ imgproxy may encode the image repeatedly to reduce its quality.
15
+ Applicable to JPEG, WebP, HEIC, and TIFF output.
16
+
17
+ Attributes:
18
+ value: Maximum requested output size in bytes; zero disables it.
19
+
20
+ Usage:
21
+
22
+ >>> option = MaxBytes(value=100_000)
23
+ >>> option.arguments
24
+ (100000,)
25
+
26
+ See `imgproxy max bytes
27
+ <https://docs.imgproxy.net/usage/processing#max-bytes>`_.
28
+
29
+ """
30
+
31
+ value: int
32
+
33
+ _name: ClassVar[OptionType] = 'mb'
34
+
35
+ @property
36
+ @override
37
+ def arguments(self) -> tuple[Argument, ...]:
38
+ """Positional arguments in imgproxy protocol order."""
39
+ return (self.value,)