polymerist.graphics.imageutils ============================== .. py:module:: polymerist.graphics.imageutils .. autoapi-nested-parse:: Tools for editing and manipulating images, and image colors, sizes, and representations Functions --------- .. autoapisummary:: polymerist.graphics.imageutils.img_from_bytes polymerist.graphics.imageutils.img_to_array polymerist.graphics.imageutils.get_axis_bounds polymerist.graphics.imageutils.get_tight_bbox polymerist.graphics.imageutils.crop_borders Module Contents --------------- .. py:function:: img_from_bytes(img_bytes: bytearray) -> PIL.Image.Image Load an image from a bytestream .. py:function:: img_to_array(image: PIL.Image.Image, encoding: str = 'RGB') -> numpy.ndarray Convert an image to a numpy array .. py:function:: get_axis_bounds(image: PIL.Image.Image, bg_color: Union[int, tuple[int]]) -> tuple[tuple[int, int], tuple[int, int]] Takes an image and returns a pair of tuples containing the min and max non-background coordinates along the x- and y-axis (respectively) for some chosen background color .. py:function:: get_tight_bbox(image: PIL.Image.Image, bg_color: Union[int, tuple[int]]) -> tuple[int, Ellipsis] Takes an image and returns a 4-tuple of the coordinates of the tight bounding box based on a choice of background color .. py:function:: crop_borders(image: PIL.Image.Image, bg_color: Union[int, tuple[int]]) -> PIL.Image.Image Takes an image and returns an image with all extraneous borders of a particular background color cropped off