[bug fix] change image file detector

This commit is contained in:
Jaric Kuo 2020-11-13 14:53:23 +08:00
parent 4eb79878dc
commit 8f360f1a01
2 changed files with 6 additions and 1 deletions

View File

@ -9,3 +9,4 @@ tqdm==4.51.0
requests==2.24.0
scipy==1.5.4
pymatting==1.1.1
filetype=1.0.7

View File

@ -2,6 +2,7 @@ import argparse
import glob
import imghdr
import os
import filetype
from distutils.util import strtobool
from ..bg import remove
@ -90,7 +91,10 @@ def main():
full_paths += glob.glob(path + "/*")
for fi in files:
if imghdr.what(fi) is None:
fi_type = filetype.guess(fi)
if fi_type is None:
continue
elif if_type.mime.find('image') < 0:
continue
with open(fi, "rb") as input: