rodrigobertin
8/15/2018 - 1:32 PM

Base 64 images in python

Base 64 images in python

import base64

def get_image_file_as_base64_data(FILEPATH):
    with open(FILEPATH, 'r') as image_file:
        return 'data:;base64,' + str(base64.b64encode(image_file.read()))