In short terms, when trying to open an image using byte data, I unfortunately end up with an error. Here is some of the code for more clarity.
test2.py:
logo = b"iVBORw0KGgoAAAA ... "
#(It's 60k characters long don't worry about it)
test.py:
import test2 as pim
import io
from PIL import Image, ImageTk
sol = io.BytesIO(pim.logo)
image = Image.open(sol)
Apparenly for some strange reason, I end up with this error:
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x0000028D819373D0>
I've tried searching on other posts. I found some similar ones, but none of the solutions worked.
@martineau actually answered the question but here is a quick runup:
Convert base64 data, use it in a bytesio class and put it into an image:
s = base64.b64decode(pim.logo)
sol = io.BytesIO(s)
image = Image.open(sol)
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.