def extract_image_information(path: Path, exif: bool = False, hash: bool = False) -> dict: """Extracts all image information per file, as opening files is slow Args: path: Path to the image exif: extract exif information hash: calculate hash (for duplicate detection) Returns: A dict containing image information """ information = {} image = open_image(path) information["opened"] = image is not None if image is not None: information["truncated"] = is_image_truncated(image) if not information["truncated"]: information["size"] = image.size if exif: information["exif"] = extract_exif(image) if hash: information["hash"] = hash_image(image) return information
def extract_image_information(path: Path) -> dict: """Extracts all image information per file, as opening files is slow Args: path: Path to the image Returns: A dict containing image information """ information = {} image = open_image(path) information["opened"] = image is not None if information["opened"]: information["truncated"] = is_image_truncated(image) if not information["truncated"]: information["size"] = image.size information["exif"] = extract_exif(image) information["hash"] = hash_image(image) # else: # print(image.size) return information