bag.corrupt_image module

Read image files and do something if they are corrupt.

bag.corrupt_image.corrupt_images(directory='.', files='*.jpg')[source]

Find corrupt images in directory.

Generator that, given a directory, goes through all files that pass through the filter files, reads them onto Pillow and yields each corrupt image path.

Example usage:

target = Path('./images/corrupt/')
target.mkdir()
for img in corrupt_images('./images/', files='*.png'):
    # Do something with *img*, which is a Path object:
    img.rename(target / img.name)  # move it
Return type

Generator[Path, None, None]

bag.corrupt_image.is_valid_image(pth)[source]

Read an image file and return whether it is valid.

Return type

bool