diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-12 13:21:03 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-12 13:21:03 +0100 |
commit | b0864d58fdb76354a667f924e9e21dd715c4e8ec (patch) | |
tree | ac7770ec948f4edc38310511098318d01923115a /xhtml2odt | |
parent | 3af31a66fb21ef91d9336ce27c42387b7e46ef65 (diff) | |
download | Ishtar-b0864d58fdb76354a667f924e9e21dd715c4e8ec.tar.bz2 Ishtar-b0864d58fdb76354a667f924e9e21dd715c4e8ec.zip |
Add image export in ODT (refs #1366)
Diffstat (limited to 'xhtml2odt')
-rwxr-xr-x | xhtml2odt/xhtml2odt.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/xhtml2odt/xhtml2odt.py b/xhtml2odt/xhtml2odt.py index 340a980cb..0923c1d05 100755 --- a/xhtml2odt/xhtml2odt.py +++ b/xhtml2odt/xhtml2odt.py @@ -458,11 +458,19 @@ class ODTFile(object): log('Forced height: %spx. Size will be: %scm x %scm' % (height_mo.group(1), height, width), self.options.verbose) full_tag = full_tag.replace(height_mo.group(), "") - else: + elif hasattr(self.options, 'img_dpi'): width = width / float(self.options.img_dpi) * INCH_TO_CM height = height / float(self.options.img_dpi) * INCH_TO_CM log('Size converted to: %scm x %scm' % (height, width), self.options.verbose) + elif hasattr(self.options, 'img_width'): + ratio = float(height) / float(width) + width = float(self.options.img_width.replace('cm', '')) + height = ratio * width + log('Size converted to: %scm x %scm' % (height, width), + self.options.verbose) + else: + return full_tag full_tag = full_tag.replace('<img', '<img width="%scm" height="%scm"' % (width, height)) return full_tag |