From de641e723aef61ae9d080d36a6986bb0d7685e67 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Oct 2015 00:17:10 +0530 Subject: [PATCH] Fix a regression that broke the heuristic used to detect cover images in some EPUB files that do not specify their cover metadata. Fixes #1509642 ["cover.jpg" generated with additional white space (for small cover jpgs)](https://bugs.launchpad.net/calibre/+bug/1509642) ["cover.jpg" generated with additional white space (for small cover jpgs)](https://bugs.launchpad.net/calibre/+bug/1509642) --- src/calibre/ebooks/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index 00a5384f96..7b2cf22eac 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -94,10 +94,12 @@ def extract_calibre_cover(raw, base, log): 'font', 'br']) images = soup.findAll('img') if matches is None and len(images) == 1 and \ - images[0].get('alt', '')=='cover': + images[0].get('alt', '').lower()=='cover': img = images[0] img = os.path.join(base, *img['src'].split('/')) - return_raster_image(img) + q = return_raster_image(img) + if q is not None: + return q # Look for a simple cover, i.e. a body with no text and only one tag if matches is None: @@ -110,7 +112,7 @@ def extract_calibre_cover(raw, base, log): images = body.findAll('img', src=True) if 0 < len(images) < 2: img = os.path.join(base, *images[0]['src'].split('/')) - return_raster_image(img) + return return_raster_image(img) def render_html_svg_workaround(path_to_html, log, width=590, height=750): from calibre.ebooks.oeb.base import SVG_NS