abstract_api.image_processing.strategies.crop package#
Submodules#
Module contents#
- class abstract_api.image_processing.strategies.crop.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.crop.CropMode(value)[source]#
Bases:
EnumDirection of cropping.
- BOTTOM = 'b'#
- BOTTOM_LEFT = 'bl'#
- BOTTOM_RIGHT = 'br'#
- CENTER = 'c'#
- EAST = 'e'#
- LEFT = 'l'#
- NORTH = 'n'#
- NORTH_EAST = 'ne'#
- NORTH_WEST = 'nw'#
- RIGHT = 'r'#
- SOUTH = 's'#
- SOUTH_EAST = 'se'#
- SOUTH_WEST = 'sw'#
- TOP = 't'#
- TOP_LEFT = 'tl'#
- TOP_RIGHT = 'tr'#
- WEST = 'w'#