class documentation

class SizeRequirements: (source)

View In Hierarchy

A set of requirements for the size of an input image.

Method __post_init__ Undocumented
Method check Returns whether the given width and height satisfy the size requirements.
Method get_padding Given an image size, this returns the minimum amount of padding necessary to satisfy the size requirements. The returned padding is in the format (pad_width, pad_height) and is guaranteed to be non-negative.
Class Variable multiple_of The width and height of the image must be a multiple of this value.
Class Variable square The image must be square.
Instance Variable minimum The minimum size of the input image in pixels.
Property none Returns True if no size requirements are specified.
def __post_init__(self): (source)

Undocumented

def check(self, width: int, height: int) -> bool: (source)

Returns whether the given width and height satisfy the size requirements.

def get_padding(self, width: int, height: int) -> tuple[int, int]: (source)

Given an image size, this returns the minimum amount of padding necessary to satisfy the size requirements. The returned padding is in the format (pad_width, pad_height) and is guaranteed to be non-negative.

multiple_of: int = (source)

The width and height of the image must be a multiple of this value.

multiple_of is guaranteed to be >= 1.

Default/neutral value: 1

square: bool = (source)

The image must be square.

Default/neutral value: False

minimum: int = (source)

The minimum size of the input image in pixels.

minimum is guaranteed to be a multiple of multiple_of and to be >= 0.

On initialization, if minimum is not a multiple of multiple_of, it will be rounded up to the next multiple of multiple_of.

Default/neutral value: 0

@property
none: bool = (source)

Returns True if no size requirements are specified.

If True, then check is guaranteed to always return True.