abstract_api.image_processing.strategies package#
Subpackages#
Submodules#
Module contents#
- class abstract_api.image_processing.strategies.Auto(*, height: int, **kwargs)[source]#
Bases:
HeightMixin,WidthMixin,BaseStrategyUse auto selected strategy.
The best strategy (portrait or landscape) will be selected according to its aspect ratio.
- class abstract_api.image_processing.strategies.BaseStrategy[source]#
Bases:
ABCBase class for all image processing strategies.
- class abstract_api.image_processing.strategies.Crop(scale: int | None = None, x: int | None = None, y: int | None = None, **kwargs)[source]#
Bases:
HeightMixin,WidthMixin,CropModeMixin,BaseStrategyCrop an image to a specified exact size.
The resulting cropped image can optionally be scaled by inclusion of a scale, which accepts a number representing the percentage by which the image should be scaled.
If you want to crop from a direction other than the default “center”, you can specify a crop_mode parameter, which can take one of the following gravity (or direction) values: n or t - North / Top nw or tl - North West / Top Left ne or tr - North East / Top Right w or l - West / Left c - Center - this is the default gravity or direction, and applied
when the crop_mode parameter is left out, or an invalid value is passed.
e or r - East / Right se or br - South East / Bottom Right sw or bl - South West / Bottom Left s or b - South / Bottom
You can also use CropMode enum to pass the crop_mode parameter.
If you would like to crop a custom area from an image, you can do so by specifying the rectangular region you wish to extract as x, y, width and height. Optionally, you can pass a scale parameter (as mentioned above), which must be a number representing the percentage by which you would like to scale the image.
- json() dict[str, int | str][source]#
Returns a dict with strategy attributes to be used with requests.
- property scale: int | None#
The percentage by which you would like to scale the image.
- property x: int | None#
X position of the rectangular area to be cropped, if needed.
- property y: int | None#
Y position of the rectangular area to be cropped, if needed.
- class abstract_api.image_processing.strategies.Exact(*, height: int, **kwargs)[source]#
Bases:
HeightMixin,WidthMixin,BaseStrategyResize to exact width and height.
Aspect ratio will not be maintained.
- class abstract_api.image_processing.strategies.Fill(background: str | None = None, **kwargs)[source]#
Bases:
HeightMixin,WidthMixin,BaseStrategyResize image to fit the specified bounds while preserving aspect ratio.
The optional background parameter allows you to specify a color which will be used to fill the unused portions of the specified bounds. The default background color is black.
- property background: str | None#
The color to be used to fill the unused portions.
- class abstract_api.image_processing.strategies.Fit(*, height: int, **kwargs)[source]#
Bases:
HeightMixin,WidthMixin,CropModeMixin,BaseStrategyCrop and resize the image to fit the desired width and height.
- class abstract_api.image_processing.strategies.Landscape(*, width: int, **kwargs)[source]#
Bases:
WidthMixin,BaseStrategyResize to exact width.
Height will be adjusted according to aspect ratio.
- class abstract_api.image_processing.strategies.Portrait(*, height: int, **kwargs)[source]#
Bases:
HeightMixin,BaseStrategyResize to exact height.
Width will be adjusted according to aspect ratio.
- class abstract_api.image_processing.strategies.Square(size: int)[source]#
Bases:
BaseStrategyCrop image by its shorter dimension to make it a square.
Image is resized after cropping to the specified size.
- json() dict[str, int | str][source]#
Returns a dict with strategy attributes to be used with requests.
- property size: int#
Size to resize the cropped image to.