aboutsummaryrefslogtreecommitdiff
path: root/mammoth/conversion.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 17:49:58 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 17:49:58 +0000
commitdd44939b3ec3c59a3c8a89e8d5d4128642bb7b59 (patch)
tree73162804e936048e67cbaf520b88754d1c609c57 /mammoth/conversion.py
parentb2db0099904e8a7e9d580e2a591b3914e187821a (diff)
Handle image encoding properly
Diffstat (limited to 'mammoth/conversion.py')
-rw-r--r--mammoth/conversion.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index 87e1bf9..b3b41d0 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -74,9 +74,7 @@ class DocumentConverter(object):
def _convert_image(self, image, html_generator):
with image.open() as image_bytes:
- output = io.BytesIO()
- base64.encode(image_bytes, output)
- encoded_src = output.getvalue().rstrip("\n")
+ encoded_src = base64.b64encode(image_bytes.read()).decode("ascii")
attributes = {
"src": "data:{0};base64,{1}".format(image.content_type, encoded_src)