Binary images can be converted to Base64 text when they need to be embedded in JSON, HTML, email, or another text-based format. Open the file in binary mode, encode its bytes with Python’s base64 module, and decode the result to UTF-8 before storing or transmitting it.
# with open(str(MEDIA_ROOT)+'/pdf/background.png', 'rb') as image_file:
# encoded_background = base64.b64encode(image_file.read()).decode('utf-8')