madam.image module
- class madam.image.FlipOrientation(value)[source]
Bases:
EnumRepresents an axis for image flip operations.
- HORIZONTAL = 0
Horizontal axis
- VERTICAL = 1
Vertical axis
- class madam.image.PillowProcessor(config: Mapping[str, Any] | None = None)[source]
Bases:
ProcessorRepresents a processor that uses Pillow as a backend.
- __init__(config: Mapping[str, Any] | None = None) None[source]
Initializes a new PillowProcessor.
- Parameters:
config – Mapping with settings.
- auto_orient(asset: Asset) Asset[source]
Creates a new asset whose essence is rotated according to the Exif orientation. If no orientation metadata exists or asset is not rotated, an identical asset object is returned.
- can_read(file: IO) bool[source]
Returns whether the specified MIME type is supported by this processor.
- Parameters:
file (IO) – file-like object to be tested
- Returns:
whether the data format of the specified file is supported or not
- Return type:
- convert(asset: Asset, mime_type: MimeType | str, color_space: str | None = None, depth: int | None = None, data_type: str | None = None) Asset[source]
Creates a new asset of the specified MIME type from the essence of the specified asset.
- Parameters:
- Returns:
New asset with converted essence
- Return type:
- crop(asset: Asset, x: int, y: int, width: int, height: int) Asset[source]
Creates a new asset whose essence is cropped to the specified rectangular area.
- Parameters:
- Returns:
New asset with cropped essence
- Return type:
- flip(asset: Asset, orientation: FlipOrientation) Asset[source]
Creates a new asset whose essence is flipped according the specified orientation.
- Parameters:
asset (Asset) – Asset whose essence is to be flipped
orientation (FlipOrientation) – axis of the flip operation
- Returns:
Asset with flipped essence
- Return type:
- read(file: IO) Asset[source]
Returns an
Assetobject whose essence is identical to the contents of the specified file.- Parameters:
file (IO) – file-like object to be read
- Returns:
Asset with essence
- Return type:
- Raises:
UnsupportedFormatError – if the specified data format is not supported
- resize(asset: Asset, width: int, height: int, mode: ResizeMode = ResizeMode.EXACT) Asset[source]
Creates a new Asset whose essence is resized according to the specified parameters.
- Parameters:
asset (Asset) – Asset to be resized
width (int) – target width
height (int) – target height
mode (ResizeMode) – resize behavior
- Returns:
Asset with resized essence
- Return type:
- class madam.image.ResizeMode(value)[source]
Bases:
EnumRepresents a behavior for image resize operations.
- EXACT = 0
Image exactly matches the specified dimensions
- FILL = 2
Image is resized to completely fill the specified dimensions
- FIT = 1
Image is resized to fit completely into the specified dimensions