Created
October 20, 2018 17:10
-
-
Save lintangsutawika/9da34ab1ab66337594ea3b647d3a8194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import base64 | |
IMAGE_FILE = "example.png" | |
with open(IMAGE_FILE, "rb") as image_file: | |
encoded_string = base64.b64encode(image_file.read()) | |
base64_string = encoded_string.decode('utf-8') | |
json_data = dumps({'image': base64_string}, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment