Jianzhong He
Jianzhong He

Reputation: 11

How to check a jpeg image whether corrupt?

Here, I use opencv imread read the all the image without any problem while it raise out Corrupt Data: xxx extraeous bytes before marker 0xd9 when training with neural networks. How could I get out these corrupt data(just select out, do not need repair or any other operations).

Upvotes: 1

Views: 2617

Answers (1)

Red
Red

Reputation: 27547

Since you only want to filter out the corrupt files, you can use a try - except block:

for file in files:
    try:
        img = cv2.imread(file)
    except:
        pass

Upvotes: 1

Related Questions