I found a thread where there is a another base64 function used for converting the data:
Signature component image to Report - Ignition Early Access - Inductive Automation Forum
I used Base64.encodeBytes() method. Now the result looks like a base64 string but it still wont render in Image component.
I was suspecting that the data the POST request returned were modified by Ignition so I tried to save the PNG data to a .png file. It seems the data are not correct and I cannot display the image file in Windows.
The code I used to get the png for saving is below:
URL = "http://api.labelary.com/v1/printers/12dpmm/labels/5.82677x8.26772/0/"
contentType = "application/x-www-form-urlencoded"
headers = {
'Accept': 'image/png',
'Content-Type': 'application/x-www-form-urlencoded'
}
res = system.net.httpPost(URL,
contentType = contentType,
postData = ZPL,
headerValues = headers,
throwOnError = False
)
filename = system.file.saveFile("image.png")
if filename is not None:
system.file.writeFile(filename, str(res))