filename = "tmp:/test_file.jpg"
b64 = <b64 String for a JPEG>
ba = CreateObject("roByteArray")
ba.FromBase64String(b64)
ba.AppendFile(filename)
canvasItems.push({url:filename,TargetRect:{x:10,y:10,w:107,h:60}})
m.canvas.SetLayer(1, canvasItems)
m.canvas.Show()
I have find this similar solution in Python language.
Base64 encoding enables us to convert bytes containing binary or text data to ASCII characters. By encoding the data, we improve the chances of it being processed correctly by various systems. Some systems don’t understand the data in bytes format, so we have to convert the data.
To convert the Image to Base64 String in Python we have to use the Python base64 module that provides b64encode() method.
The purpose of the base64.b64encode() method in Python is to convert the binary data into ASCII-safe “text”. But Python strongly disagrees with that. Python is now very strict about this that bytes.encode() method doesn’t even exist, and so ‘xyz’.encode(‘base64’) would raise an AttributeError.