Created
June 3, 2024 13:14
-
-
Save snobu/31fb185d193766bd83a7329e0cef085f to your computer and use it in GitHub Desktop.
Image to base64
This file contains hidden or 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
# Open the image file and encode it as a base64 string | |
def encode_image(image_path): | |
with open(image_path, "rb") as image_file: | |
return base64.b64encode(image_file.read()).decode("utf-8") | |
base64_image = encode_image(IMAGE_PATH) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment