From 740053ed367ac4be3cfb6882dfbc4db47f0a774c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 13 Sep 2013 15:18:10 +0530 Subject: [PATCH] DOCX Input: Do not fail if the firs image is an EMF image Fixes #1224849 [DOCX to EPUB conversion failed with devide by zero](https://bugs.launchpad.net/calibre/+bug/1224849) --- src/calibre/ebooks/docx/cleanup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/cleanup.py b/src/calibre/ebooks/docx/cleanup.py index bb421afc89..cea90f137f 100644 --- a/src/calibre/ebooks/docx/cleanup.py +++ b/src/calibre/ebooks/docx/cleanup.py @@ -173,7 +173,10 @@ def cleanup_markup(log, root, styles, dest_dir, detect_cover): width, height, fmt = identify(path) except: width, height, fmt = 0, 0, None - is_cover = 0.8 <= height/width <= 1.8 and height*width >= 160000 + try: + is_cover = 0.8 <= height/width <= 1.8 and height*width >= 160000 + except ZeroDivisionError: + is_cover = False if is_cover: log.debug('Detected an image that looks like a cover') img.getparent().remove(img)