pic_scanner.helpers.images
Attributes
Functions
|
Draw bounding boxes around areas of concern in an image. |
|
Get image data from a file or a bytes object. |
|
Get the checksum of an image file. |
Module Contents
- pic_scanner.helpers.images.PARENT_LOGGER
- pic_scanner.helpers.images.MOD_LOGGER
- pic_scanner.helpers.images.draw_bounding_boxes(image_path, concerns, box_color=(255, 0, 0), text_color=(255, 255, 255), save_path=None, save_annotated=False)
Draw bounding boxes around areas of concern in an image.
- Parameters:
image_path (str) – The path to the image.
concerns (list) – The areas of concern in the image.
save_path (str) – The path to save the annotated image.
save_annotated (bool) – A flag indicating whether to save the annotated image.
- Returns:
The image with the bounding boxes drawn.
- Return type:
Image
- pic_scanner.helpers.images.get_image_data(file_or_bytes: str | bytes, maxsize: Tuple[int, int] = (1200, 850)) bytes
Get image data from a file or a bytes object.
This function opens an image file or a bytes object, resizes it to fit within the given maximum size, and returns the image data in PNG format as bytes.
- Parameters:
file_or_bytes (Union[str, bytes]) – The path to the image file or a bytes object containing the image data.
maxsize (Tuple[int, int], optional) – The maximum size of the image as a (width, height) tuple. Default is (1200, 850).
- Returns:
The image data as a byte-string object in PNG format.
- Return type:
bytes
- Raises:
FileNotFoundError – If the specified file does not exist.
OSError – If the file cannot be opened and identified as an image file.
ValueError – If the input bytes object cannot be decoded into an image.
- pic_scanner.helpers.images.get_image_checksum(image_path: str | pathlib.Path)
Get the checksum of an image file.
- Parameters:
image_path (Union[str, Path]) – The path to the image file.
- Returns:
The checksum of the image file.
- Return type:
str