This commit is contained in:
Kovid Goyal 2016-05-05 08:15:08 +05:30
parent 0ae69c8f96
commit 6f48fe28e2
2 changed files with 3 additions and 1 deletions

View File

@ -29,6 +29,8 @@ def get_cover(docx):
fmt, width, height = identify(bytes(raw))
except Exception:
continue
if width < 0 or height < 0:
continue
if 0.8 <= height/width <= 1.8 and height*width >= 160000:
return (fmt, raw)

View File

@ -259,7 +259,7 @@ def read_cover(stream, zin, mi, opfmeta, extract_cover):
if not cover_data:
raw = zin.read(cover_href)
try:
fmt, width, height = identify(bytes(raw))
fmt = identify(bytes(raw))[0]
except Exception:
pass
else: