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/')
for img in corrupt_images('./images/', files='*.png'):
    # Do something with *img*, which is a Path object:
    img.rename(target /  # move it
Return type:Generator[Path, None, None]

Read an image file and return whether it is valid.

Return type:bool