Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions pyimgproxy/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def resizing_type(self, resizing_type: str) -> "Image":

def resizing_algorithm(self, resizing_algorithm: str) -> "Image":
"""
This option is only available in imgproxy Pro.

Defines the algorithm that imgproxy will use for resizing. Supported algorithms are
`nearest`, `linear`, `cubic`, `lanczos2`, and `lanczos3`.

Expand Down Expand Up @@ -205,8 +207,9 @@ def extend(
"""
- When extend is set to `True`, imgproxy will extend the image if it is smaller than the
given size.
- `gravity_type` (optional) accepts the same values as the gravity option, except `sm`.
When `gravity` is not set, imgproxy will use `ce` gravity without offsets.
- `gravity_type` (optional) accepts the same values as the gravity option, except `sm`,
`obj` and `objw`. When `gravity_type` is not set, imgproxy will use `ce` gravity without
offsets.

Default: `false:ce:0:0`
"""
Expand All @@ -222,8 +225,9 @@ def extend_aspect_ratio(
"""
- When extend is set to `True`, imgproxy will extend the image to the requested aspect
ratio.
- `gravity_type` (optional) accepts the same values as the gravity option, except `sm`.
When `gravity_type` is not set, imgproxy will use `ce` gravity without offsets.
- `gravity_type` (optional) accepts the same values as the gravity option, except `sm`,
`obj` and `objw`. When `gravity_type` is not set, imgproxy will use `ce` gravity without
offsets.

Default: `false:ce:0:0`
"""
Expand Down Expand Up @@ -290,6 +294,10 @@ def trim(
"""
Removes surrounding background.

Trimming requires an image to be fully loaded into memory. This disables scale-on-load and
significantly increases memory usage and processing time. Use it carefully with large
images.

- `threshold` - color similarity tolerance.
- `color` - (optional) a hex-coded value of the color that needs to be cut off.
- `equal_hor` - (optional) set to `True`, imgproxy will cut only equal parts from left and
Expand Down Expand Up @@ -368,6 +376,8 @@ def background(

def background_alpha(self, alpha: int | float) -> "Image":
"""
This option is only available in imgproxy Pro.

Adds an alpha channel to `background`. The value of `alpha` is a positive floating point
number between `0` and `1`.

Expand All @@ -382,13 +392,17 @@ def adjust(
saturation: int | float | None = None,
) -> "Image":
"""
This option is only available in imgproxy Pro.

This is a meta-option that defines the brightness, contrast, and saturation. All arguments
are optional and can be omitted to use their default values.
"""
return self.add_option("adjust", brightness, contrast, saturation)

def brightness(self, brightness: int) -> "Image":
"""
This option is only available in imgproxy Pro.

When set, imgproxy will adjust brightness of the resulting image. `brightness` is an
integer number ranging from `-255` to `255`.

Expand All @@ -398,6 +412,8 @@ def brightness(self, brightness: int) -> "Image":

def contrast(self, contrast: int | float) -> "Image":
"""
This option is only available in imgproxy Pro.

When set, imgproxy will adjust the contrast of the resulting image. `contrast` is a
positive floating point number, where a value of `1` leaves the contrast unchanged.

Expand All @@ -407,6 +423,8 @@ def contrast(self, contrast: int | float) -> "Image":

def saturation(self, saturation: int | float) -> "Image":
"""
This option is only available in imgproxy Pro.

When set, imgproxy will adjust saturation of the resulting image. `saturation` is a
positive floating-point number, where a value of `1` leaves the saturation unchanged.

Expand Down Expand Up @@ -451,13 +469,17 @@ def unsharp_masking(
divider: int | float | None = None,
) -> "Image":
"""
This option is only available in imgproxy Pro.

Allows redefining unsharp masking options. All arguments have the same meaning as Unsharp
masking configs. All arguments are optional and can be omitted.
"""
return self.add_option("unsharp_masking", mode, weight, divider)

def blur_detections(self, sigma: int | float, class_names: list[str] | None = None) -> "Image":
"""
This option is only available in imgproxy Pro.

imgproxy detects objects of the provided classes and blurs them. If class names are
omitted, imgproxy blurs all the detected objects.

Expand All @@ -469,6 +491,8 @@ def blur_detections(self, sigma: int | float, class_names: list[str] | None = No

def draw_detections(self, draw: bool, class_names: list[str] | None = None) -> "Image":
"""
This option is only available in imgproxy Pro.

When draw is set to `True`, imgproxy detects objects of the provided classes and draws
their bounding boxes. If class names are omitted, imgproxy draws the bounding boxes of all
the detected objects.
Expand Down Expand Up @@ -573,6 +597,8 @@ def format(self, extension: str) -> "Image":

def page(self, page: int) -> "Image":
"""
This option is only available in imgproxy Pro.

When a source image supports pagination (PDF, TIFF) or animation (GIF, WebP), this option
allows specifying the page to use. Page numeration starts from zero.

Expand All @@ -586,6 +612,8 @@ def page(self, page: int) -> "Image":

def pages(self, pages: int) -> "Image":
"""
This option is only available in imgproxy Pro.

When a source image supports pagination (PDF, TIFF) or animation (GIF, WebP), this option
allows specifying the number of pages to use. The pages will be stacked vertically and
left-aligned.
Expand All @@ -600,6 +628,8 @@ def pages(self, pages: int) -> "Image":

def disable_animation(self, disable: bool) -> "Image":
"""
This option is only available in imgproxy Pro.

When set to `True`, imgproxy will treat all images as not animated. Use the `page` and the
`pages` options to specify which frames imgproxy should use.

Expand Down