mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
47729eab47
commit
4336c25193
@ -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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user