Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pillow verify()未找到损坏的JPG_Python_Python Imaging Library_Verify_Corrupt - Fatal编程技术网

Python Pillow verify()未找到损坏的JPG

Python Pillow verify()未找到损坏的JPG,python,python-imaging-library,verify,corrupt,Python,Python Imaging Library,Verify,Corrupt,我遵循了一个包含以下Python代码的教程来查找损坏的jpg文件。我有一个损坏的jpg,我已经在上面测试过了,但是脚本没有找到这个文件。我有什么遗漏吗?运行Python3.9 编辑:对不起,我忘了说。我在自己的脚本中将“if endswith”改为“.jpg”。这只是本教程的一个副本 您只检查png files.change if filename.endswith('.png'):`to if filename.endswith('.jpg'):`谢谢,我在自己的脚本中将那一行更改为'.jpg

我遵循了一个包含以下Python代码的教程来查找损坏的jpg文件。我有一个损坏的jpg,我已经在上面测试过了,但是脚本没有找到这个文件。我有什么遗漏吗?运行Python3.9

编辑:对不起,我忘了说。我在自己的脚本中将“if endswith”改为“.jpg”。这只是本教程的一个副本


您只检查png files.change if filename.endswith('.png'):`to if filename.endswith('.jpg'):`谢谢,我在自己的脚本中将那一行更改为'.jpg'。我直接从这篇文章的教程中复制了这段代码。我编辑了我的帖子来反映这一点。更多信息。它确实检测到损坏的0字节CR2摄像机原始文件。我一直在使用的jpg不是零字节,但有一半没有正确加载。您是否有一个您认为
verify()
应该标记的损坏图像的示例?您只检查png文件。更改if filename.endswith('.png'):`to if filename.endswith('.jpg'):`谢谢,我在自己的脚本中将该行更改为'.jpg'。我直接从这篇文章的教程中复制了这段代码。我编辑了我的帖子来反映这一点。更多信息。它确实检测到损坏的0字节CR2摄像机原始文件。我一直在使用的jpg不是零字节,但有一半没有正确加载。您是否有一个您认为
verify()
应该标记的损坏映像的示例?
from os import listdir
from PIL import Image



for filename in listdir('./'):

  if filename.endswith('.png'):`
      try:
          img = Image.open('./'+filename) # open the image file
          img.verify() # verify that it is, in fact an image
      except (IOError, SyntaxError) as e:
          print('Bad file:', filename) # print out the names of corrupt files