madam.image
module¶
-
class
madam.image.
FlipOrientation
[source]¶ Bases:
enum.Enum
Represents an axis for image flip operations.
-
HORIZONTAL
= 0¶ Horizontal axis
-
VERTICAL
= 1¶ Vertical axis
-
-
class
madam.image.
PillowProcessor
(config: Optional[Mapping[str, Any]] = None)[source]¶ Bases:
madam.core.Processor
Represents a processor that uses Pillow as a backend.
-
__init__
(config: Optional[Mapping[str, Any]] = None) → None[source]¶ Initializes a new PillowProcessor.
Parameters: config – Mapping with settings.
-
auto_orient
(asset: madam.core.Asset) → madam.core.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.
Parameters: asset (Asset) – Asset with orientation metadata Returns: Asset with rotated essence Return type: Asset
-
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: bool
-
convert
(asset: madam.core.Asset, mime_type: Union[madam.mime.MimeType, str], color_space: Optional[str] = None, depth: Optional[int] = None, data_type: Optional[str] = None) → madam.core.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: madam.core.Asset, x: int, y: int, width: int, height: int) → madam.core.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: madam.core.Asset, orientation: madam.image.FlipOrientation) → madam.core.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) → madam.core.Asset[source]¶ Returns an
Asset
object 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: Asset Raises: UnsupportedFormatError – if the specified data format is not supported
-
resize
(asset: madam.core.Asset, width: int, height: int, mode: madam.image.ResizeMode = <ResizeMode.EXACT: 0>) → madam.core.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
[source]¶ Bases:
enum.Enum
Represents 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
-