Python Script to detect broken images

后端 未结 4 2065
深忆病人
深忆病人 2021-01-24 07:10

I wrote a python script to detect broken images and count them, The problem in my script is it detects all the images and does not detect broken images. How to fix this. I refe

4条回答
  •  旧巷少年郎
    2021-01-24 07:41

    You are building a bad path with

    img=Image.open('/Users/ajinkyabobade/Desktop/2'+filename)      
    

    Try the following instead (by adding / to the end of the directory path)

    img=Image.open('/Users/ajinkyabobade/Desktop/2/'+filename)      
    

    or

    img=Image.open(os.path.join('/Users/ajinkyabobade/Desktop/2', filename))
    

提交回复
热议问题