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)

This commit is contained in:
Kovid Goyal 2017-10-08 10:52:59 +05:30
parent e972119109
commit 4307856fa9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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)