Skip to content

Commit a04ed29

Browse files
aarbouinalexysdussier
authored andcommitted
Create helper to convert EMU to pixel
1 parent 92f2f24 commit a04ed29

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mammoth/docx/body_xml.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from .styles_xml import Styles
1111
from .uris import replace_fragment, uri_to_zip_entry_name
1212

13+
EMU_TO_PIXEL = 1 / 9525
14+
1315
if sys.version_info >= (3, ):
1416
unichr = chr
1517

@@ -395,6 +397,9 @@ def inline(element):
395397
.find_children("a:blip")
396398
return _read_blips(blips, alt_text)
397399

400+
def _emu_to_pixel(emu):
401+
return round(int(emu) * EMU_TO_PIXEL)
402+
398403
def _read_blips(blips, alt_text):
399404
return _ReadResult.concat(lists.map(lambda blip: _read_blip(blip, alt_text), blips))
400405

0 commit comments

Comments
 (0)