DOCX Output: Fix aspect ratio of images being distorted when the input document specifies image width but not height or vice-versa. See #1455502 (EPUB to DOCX Conversation)

This commit is contained in:
Kovid Goyal 2015-06-04 10:04:23 +05:30
parent 47729eab47
commit 4336c25193

View File

@ -535,7 +535,13 @@ class Style(object):
def img_size(self, width, height): def img_size(self, width, height):
' Return the final size of an <img> given that it points to an image of size widthxheight ' ' Return the final size of an <img> given that it points to an image of size widthxheight '
return self.img_dimension('width', width), self.img_dimension('height', height) w, h = self._get('width'), self._get('height')
answ, ansh = self.img_dimension('width', width), self.img_dimension('height', height)
if w == 'auto' and h != 'auto':
answ = (float(width)/height) * ansh
elif h == 'auto' and w != 'auto':
ansh = (float(height)/width) * answ
return answ, ansh
@property @property
def width(self): def width(self):