From 4307856fa9db1fddc06908c94eb5572240052421 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 8 Oct 2017 10:52:59 +0530 Subject: [PATCH] DOCX Output: Fix preserve cover aspect ratio option still distorting the aspect ratio slightly. Fixes #1721864 [Preserve Aspect Ration Stretches Image](https://bugs.launchpad.net/calibre/+bug/1721864) --- src/calibre/ebooks/docx/writer/images.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/docx/writer/images.py b/src/calibre/ebooks/docx/writer/images.py index e1d4fafef2..4c3781a4f1 100644 --- a/src/calibre/ebooks/docx/writer/images.py +++ b/src/calibre/ebooks/docx/writer/images.py @@ -189,9 +189,11 @@ class ImagesManager(object): makeelement, namespaces = self.document_relationships.namespace.makeelement, self.document_relationships.namespace.namespaces if preserve_aspect_ratio: if img.width >= img.height: - height *= img.height / img.width + ar = img.height / img.width + height = ar * width else: - width *= img.width / img.height + ar = img.width / img.height + width = ar * height root = etree.Element('root', nsmap=namespaces) ans = makeelement(root, 'w:drawing', append=False)