imagesize
imagesize ¶
Module for ImageSize
Classes¶
ImageSize ¶
Class to represent the size of images
Functions¶
__eq__ ¶
Checks if two ImageSizes are equal
__le__ ¶
__lt__ ¶
__mul__ ¶
__str__ ¶
__truediv__ ¶
create_with_same_aspect_ratio ¶
Creates an ImageSize with the same aspect ratio given either width or height of the target ImageSize
Parameters:
-
width
(Optional[int]
, default:None
) –width of the target ImageSize
-
height
(Optional[int]
, default:None
) –height of the target ImageSize
Returns:
-
ImageSize
–new ImageSize, based on height or width, with the same aspect ratio as the
-
ImageSize
–original Image Size
Source code in niceml/utilities/imagesize.py
from_numpy_shape
classmethod
¶
from_pil_image
classmethod
¶
from_pil_size
classmethod
¶
get_division_factor ¶
Calculates the scale factor of two ImageSizes and returns it
Source code in niceml/utilities/imagesize.py
np_array_has_same_size ¶
Checks if the np_array has the same size as the ImageSize
to_numpy_shape ¶
ImageSizeDivisionError ¶
Bases: Exception
Error for if two ImageSizes have different aspect ratios
Functions¶
create_image_size ¶
Creates an ImageSize with: - a list of two ints [width, height] - a Tuple of two ints (width, height) - a str of form 'width,height, which will be parsed
Parameters:
-
argument
(Union[str, List[int], Tuple[int, int], dict]
) –List, Tuple or String containing width and height information
Returns:
-
ImageSize
–ImageSize with given width and height