A memo of the code used to encode the image with WebSocket and then send it with Base64. Is there an easier way?
import base64
img_file = 'hoge.jpg'
b64 = base64.encodestring(open(img_file, 'rb').read())
try:
# Python2
print('b64=' + b64)
except TypeError:
# Python3
print('b64=' + b64.decode('utf8'))
Recommended Posts