From 9556e47b51daea1ea4a17e29065aeca3e672f683 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Feb 2013 21:01:44 +0530 Subject: [PATCH] Polish books: Use the actual cover image dimensions when creating the svg wrapper for the cover image. Fixes #1127273 (Polish update cover - svg jpg dimensions wrong) --- src/calibre/ebooks/oeb/polish/cover.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/cover.py b/src/calibre/ebooks/oeb/polish/cover.py index e246476d0a..a5d7560989 100644 --- a/src/calibre/ebooks/oeb/polish/cover.py +++ b/src/calibre/ebooks/oeb/polish/cover.py @@ -11,6 +11,7 @@ import shutil, re, os from calibre.ebooks.oeb.base import OPF, OEB_DOCS, XPath, XLINK, xml2text from calibre.ebooks.oeb.polish.replace import replace_links +from calibre.utils.magick.draw import identify def set_azw3_cover(container, cover_path, report): name = None @@ -144,6 +145,10 @@ def create_epub_cover(container, cover_path): templ = CoverManager.NONSVG_TEMPLATE.replace('__style__', style) else: width, height = 600, 800 + try: + width, height = identify(cover_path)[:2] + except: + container.log.exception("Failed to get width and height of cover") ar = 'xMidYMid meet' if keep_aspect else 'none' templ = CoverManager.SVG_TEMPLATE.replace('__ar__', ar) templ = templ.replace('__viewbox__', '0 0 %d %d'%(width, height))