I am currently doing this for bytestring conversion but I need to convert to string.
img=Image.fromarray(img)
output = io.BytesIO()
img.save(output, format="png")
image_as_string = output.getvalue()
img=Image.open(io.BytesIO(image_as_string))
img.save('strimg.png')
Here is my solution with base64.
import base64
img = Image.open("test.png")
output = io.BytesIO()
img.save(output, format="png")
image_as_string = base64.b64encode(output.getvalue())
#encrypting/decrypting
img=Image.open(io.BytesIO(base64.b64decode(image_as_string)))
img.save('string.png')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.