Show More
@@ -5,12 +5,7 b'' | |||
|
5 | 5 | # Distributed under the terms of the Modified BSD License. |
|
6 | 6 | |
|
7 | 7 | |
|
8 | try: | |
|
9 | from base64 import encodebytes as base64_encode | |
|
10 | except ImportError: | |
|
11 | from base64 import encodestring as base64_encode | |
|
12 | ||
|
13 | from binascii import b2a_hex | |
|
8 | from binascii import b2a_hex, b2a_base64 | |
|
14 | 9 | import json |
|
15 | 10 | import mimetypes |
|
16 | 11 | import os |
@@ -1135,6 +1130,7 b' class Image(DisplayObject):' | |||
|
1135 | 1130 | |
|
1136 | 1131 | def _data_and_metadata(self): |
|
1137 | 1132 | """shortcut for returning metadata with shape information, if defined""" |
|
1133 | b64_data = b2a_base64(self.data).decode('ascii') | |
|
1138 | 1134 | md = {} |
|
1139 | 1135 | if self.metadata: |
|
1140 | 1136 | md.update(self.metadata) |
@@ -1145,9 +1141,9 b' class Image(DisplayObject):' | |||
|
1145 | 1141 | if self.unconfined: |
|
1146 | 1142 | md['unconfined'] = self.unconfined |
|
1147 | 1143 | if md: |
|
1148 |
return |
|
|
1144 | return b64_data, md | |
|
1149 | 1145 | else: |
|
1150 |
return |
|
|
1146 | return b64_data | |
|
1151 | 1147 | |
|
1152 | 1148 | def _repr_png_(self): |
|
1153 | 1149 | if self.embed and self.format == u'png': |
@@ -1246,7 +1242,7 b' class Video(DisplayObject):' | |||
|
1246 | 1242 | # unicode input is already b64-encoded |
|
1247 | 1243 | b64_video = video |
|
1248 | 1244 | else: |
|
1249 |
b64_video = base64 |
|
|
1245 | b64_video = b2a_base64(video).decode('ascii').rstrip() | |
|
1250 | 1246 | |
|
1251 | 1247 | output = """<video controls> |
|
1252 | 1248 | <source src="data:{0};base64,{1}" type="{0}"> |
General Comments 0
You need to be logged in to leave comments.
Login now