aboutsummaryrefslogtreecommitdiff
path: root/mammoth/conversion.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-17 20:17:17 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-17 20:17:17 +0000
commitfaae8466ac51b22a9b836103ce6e5c039dfc7eea (patch)
treed746a9cf81abefc626c651756367c97dbbeb77bf /mammoth/conversion.py
parenta2d5ef8d5590bfb7d7b038d7753b8d8b2b013ecd (diff)
Add --output-dir option
Diffstat (limited to 'mammoth/conversion.py')
-rw-r--r--mammoth/conversion.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index b324c16..835cb6b 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -73,11 +73,8 @@ class DocumentConverter(object):
def _convert_image(self, image, html_generator):
- image_bytes = image.open()
- try:
+ with image.open() as image_bytes:
encoded_src = base64.b64encode(image_bytes.read()).decode("ascii")
- finally:
- image_bytes.close()
attributes = {
"src": "data:{0};base64,{1}".format(image.content_type, encoded_src)