python3模块使用imagemagick中的“identify”作为底层机制来检查损坏的图像。
checkcorruptedimages的Python项目详细描述
检查损坏的图像
python3模块使用imagemagick中的“identify”作为底层机制来检查损坏的图像。
安装
使用pip
安装pip3 install -U checkcorruptedimages
用法
In [1]: import checkcorruptedimages
In [2]: from pathlib import Path
In [3]: m = checkcorruptedimages.CheckCorruptedImages()
In [4]: m.verbose = True
In [5]: m.get_corrupted_images(
folder_to_check=Path("/home/user/Pictures"),
file_extensions_list=["jpg"]
)
Path: /home/user/Pictures/notcorruptedimage.jpg, corrupted: False
Path: /home/user/Pictures/corruptedimage.jpg, corrupted: True
Out[5]: [PosixPath('/home/user/Pictures/corruptedimage.jpg'),
PosixPath('/home/user/Pictures/corruptedimage2.jpg'
]