I saw a lot of q&a about converting images to base 64 string from image, all of them involving saving the image physically on pc. What I want is convert the image to base 64 string without the need to save the image physically.
How can I do it with pyscreenshot
or ImageGrab
?
buffer = io.BytesIO()
im=ImageGrab.grab()
im.save(buffer, format='PNG')
im.close()
b64_str = base64.b64encode(buffer.getvalue())
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.